Open AntonVoronkin opened 1 year ago
Hey @AntonVoronkin, thanks for reporting this issue!
This is most likely due to our File I/O instrumentation feature, which wraps uses of FileInputStream
. This also means the root cause is not the sentry SDK but rather the wrapped implementation, in your case androidx.core.graphics.TypefaceCompatUtil.java
.
Could you try to build an app without Sentry instrumentation enabled? Even if disabled you should still experience the StrictMode crash.
app/build.gradle
import io.sentry.android.gradle.extensions.InstrumentationFeature
sentry {
// other config...
tracingInstrumentation {
enabled.set(false)
}
}
I completely removed sentry (including gradle file), but the problem remained.
@AntonVoronkin thanks for confirming, I'm gonna close the issue then as it seems to be unrelated to Sentry, but feel free to comment here again if you find out the problem is in our SDK. Thank you!
I'm sorry, yesterday I got too caught up and gave the wrong answer. If the sentry is removed completely, the issue does NOT occur. @romtsn
@AntonVoronkin alright we'll investigate on our side and come back, thanks
There is a PR with some improvement related to Closeable resources. However, we have to investigate the native layer, yet: removing it makes this issue disappear.
Note: there are no specific steps to reproduce this issue. Just bundle sentry-native inside, and after a while you should get it
@stefanosiano maybe it's worth a try to reproduce this again with the recent fix in sentry-native?
After some more testing this is happening for me even when the NDK is disabled.
sentry sample app
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedClosableObjects()
.penaltyLog().penaltyDeath()
.build());
SentryAndroid.init(
this,
options -> {
options.setDsn("https://1053864c67cc410aa1ffc9701bd6f93d@o447951.ingest.sentry.io/5428559");
options.setEnableNdk(false);
});
results in
StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. Callsite: close
at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1992)
at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:347)
at sun.nio.fs.UnixSecureDirectoryStream.finalize(UnixSecureDirectoryStream.java:580)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
at java.lang.Daemons$Daemon.run(Daemons.java:139)
at java.lang.Thread.run(Thread.java:920)
2023-11-29 15:43:05.201 29115-29127 System.err io.sentry.samples.android W StrictMode VmPolicy violation with POLICY_DEATH; shutting down.
Let's try without even packaging the NDK
Integration
sentry-android
Build System
Gradle
AGP Version
7.4.1
Proguard
Enabled
Version
6.27.0
Steps to Reproduce
The application crashes with StrictMode error after sentry initialization on android api 31, 32, 33. StrictMode policy for detect the SQL leaked, the closable objects leaked and detecting network operations.
Apparently, the issue is related to "android.appcompat:appcompat-resources:1.4.2 and android.appcompat:appcompat:1.4.2" entries present in the sentry-external-modules.txt file.
Sentry plugin version: 3.11.1; sentry version: 6.27.0 (6.28.0 dont' fix this problem); targetAndroidSdkVersion 31; minAndroidSdkVersion 24
Error example:
Expected Result
There are no memory leaks.
Actual Result
There are memory leaks.