analytics-android icon indicating copy to clipboard operation
analytics-android copied to clipboard

analytics-android should provide resilience on corrupted QueueFile

Open segfault87 opened this issue 2 years ago • 0 comments

We are getting following error from a certain point after upgrading android target SDK from 28 to 29 and rendering the library stop working for some users.

 2022-03-03 14:03:50.415 5511-5724/? E/Analytics: Error while uploading payloads
    java.io.IOException: At least one payload must be provided.
        at com.segment.analytics.SegmentIntegration$BatchPayloadWriter.endBatchArray(SourceFile:3)
        at com.segment.analytics.SegmentIntegration.performFlush(SourceFile:9)
        at com.segment.analytics.SegmentIntegration$3.run(SourceFile:2)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)
        at com.segment.analytics.internal.Utils$AnalyticsThread.run(SourceFile:2)

After some research, we found out a single payload is larger than 475 KB and this is the cause of the exception.

In our case, newSize was 1702131567. Something's definitely wrong with the number.

So we managed to dump and inspect the queue file and found out the file is completely corrupt.

스크린샷 2022-03-03 오후 6 37 54

1702131567 can be translated to 0x6574776f. First four bytes should be payload length but we can see a part of payload data is taking the space instead.

We still haven't figured out what's causing this. Aside of that we think the library should run nonetheless the queue file is corrupt (by clearing up corrupt files).

segfault87 avatar Mar 03 '22 09:03 segfault87