sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

DiskReadViolation when calling Sentry.captureException()

Open mhernand40 opened this issue 3 years ago • 1 comments

Integration

sentry-android

Build System

Gradle

AGP Version

7.2.1

Proguard

Enabled

Version

6.3.0

Steps to Reproduce

I do not have a sample project on hand for the repro. But the project I am working on reports Strict Mode violations as non-fatal errors and we are seeing the following non-fatal error stack trace when calling Sentry.captureException:

android.os.strictmode.DiskReadViolation: null
    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1659)
    at libcore.io.BlockGuardOs.statvfs(BlockGuardOs.java:425)
    at libcore.io.ForwardingOs.statvfs(ForwardingOs.java:859)
    at android.system.Os.statvfs(Os.java:924)
    at android.os.StatFs.doStat(StatFs.java:51)
    at android.os.StatFs.<init>(StatFs.java:43)
    at io.sentry.SentryClient.processEvent(SourceFile:292)
    at io.sentry.SentryClient.captureEvent(SourceFile:114)
    at io.sentry.Hub.captureExceptionInternal(SourceFile:226)
    at io.sentry.Hub.captureException(SourceFile:193)
    at io.sentry.IHub.captureException
    at io.sentry.Sentry.captureException

Our project is configured with detectDiskReads enabled. The assumption was that Sentry.captureException() can be called from any thread including the main thread.

Expected Result

Sentry.captureException() should not trigger a DiskReadViolation when called on the main thread.

Actual Result

Sentry.captureException() triggers a DiskReadViolation when called on the main thread.

mhernand40 avatar Aug 02 '22 19:08 mhernand40

The SDK process events on the calling thread, that means EventProcessors and BeforeSend callback also runs on the calling thread. We then queue the event for submission on a background thread. Some of the event data requires disk I/O so to completely avoid this disk read violation, we'd need to go through the SDK and rip any context data added that relies on it.

Is this causing any issues, like noticiable slowdowns for any sort? It hasn't been a problem other than raising this event if that flag is enabled.

The work around for now is to disable detectDiskReads if Sentry is enabled since doing that by itself isn't a problem

bruno-garcia avatar Aug 09 '22 19:08 bruno-garcia

Similar to https://github.com/getsentry/sentry-java/issues/909

marandaneto avatar Aug 16 '22 09:08 marandaneto

Closing due to inactivity, please feel free to reopen if you have anything to share.

adinauer avatar Sep 14 '22 13:09 adinauer