sentry-java: Android 11 + targetSdkVersion 30 crashes Sentry on start

Platform:

  • Android, targetSdkVersion 30
  • Java
  • Kotlin
  • NDK
  • React-Native

IDE:

  • Android Studio
  • IntelliJ
  • Other

The version of sentry-android: 2.3.0(at least) - master


I have the following issue:

When I set the targetSdkVersion to 30 for my app and launch it on an Android 11 device (my Pixel 4XL), the app crashes immediately.

Steps to reproduce:

  1. Clone the sentry-android repository
  2. Change the example app to use targetSdkVersion 30.
diff --git a/sentry-samples/sentry-samples-android/build.gradle.kts b/sentry-samples/sentry-samples-android/build.gradle.kts
index 5c29345..d299d1b 100644
--- a/sentry-samples/sentry-samples-android/build.gradle.kts
+++ b/sentry-samples/sentry-samples-android/build.gradle.kts
@@ -10,7 +10,7 @@ android {
     defaultConfig {
         applicationId = "io.sentry.samples.android"
         minSdkVersion(Config.Android.minSdkVersionNdk)
-        targetSdkVersion(Config.Android.targetSdkVersion)
+        targetSdkVersion(30)
         versionCode = 2
         versionName = "1.1.0"
  1. launch sentry-samples-android

Actual result:

  • Immediate crash
            libc  F  Pointer tag for 0x79f0abdc30 was truncated.
          Sentry  D  Processing dir. /data/user/0/io.sentry.samples.android/cache/sentry/sessions
            libc  F  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 15999 (samples.android), pid 15999 (samples.android)
          Sentry  D  Processing 6 items from cache dir /data/user/0/io.sentry.samples.android/cache/sentry/sessions
                  D  Processing file: /data/user/0/io.sentry.samples.android/cache/sentry/sessions/f146b6e6-91af-4a2f-a08c-014613f5e594.envelope
                  D  Processing Envelope with 1 item(s)
                  D  Captured Envelope is already cached
                  D  Item 1 is being captured.
                  D  Going to wait flush 1 item.
TetheringManager  I  registerTetheringEventCallback:io.sentry.samples.android
           DEBUG  F  #00 pc 000000000004de4c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: 03452a4a418e14ff93948f26561eace6)
                  F  getsentry/sentry-android#1 pc 000000000003bb34  /apex/com.android.runtime/lib64/bionic/libc.so (free+96) (BuildId: 03452a4a418e14ff93948f26561eace6)
                  F  getsentry/sentry-android#2 pc 00000000000781a8  /data/app/~~gQctd6Q5azmrHpqfGRaWvQ==/io.sentry.samples.android-IaNp2cunocnQXp3s03mjng==/lib/arm64/libsentry.so (sentry_f
                     ree+36) (BuildId: a8252e0bb65f23db1c6420f10a30b2f3b1477309)
                  F  getsentry/sentry-android#3 pc 0000000000085880  /data/app/~~gQctd6Q5azmrHpqfGRaWvQ==/io.sentry.samples.android-IaNp2cunocnQXp3s03mjng==/lib/arm64/libsentry.so (BuildId:
                      a8252e0bb65f23db1c6420f10a30b2f3b1477309)
                  F  getsentry/sentry-android#4 pc 0000000000085710  /data/app/~~gQctd6Q5azmrHpqfGRaWvQ==/io.sentry.samples.android-IaNp2cunocnQXp3s03mjng==/lib/arm64/libsentry.so (sentry_v
                     alue_decref+92) (BuildId: a8252e0bb65f23db1c6420f10a30b2f3b1477309)
                  F  getsentry/sentry-android#5 pc 000000000007f038  /data/app/~~gQctd6Q5azmrHpqfGRaWvQ==/io.sentry.samples.android-IaNp2cunocnQXp3s03mjng==/lib/arm64/libsentry.so (BuildId:
                      a8252e0bb65f23db1c6420f10a30b2f3b1477309)

Expected result:

  • No crash

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 49 (28 by maintainers)

Commits related to this issue

Most upvoted comments

Same here. I have tested this thing on the Pixel 4a with OS 11 and it doesn’t work but it works on the Pixel 3a with OS 11. Something wrong on the Pixel 4* with OS 11…

not sure, it could be though, we’ve ordered a pixel 4 but it didn’t arrive yet.

meantime if somebody has a physical pixel 4, you could try this workaround too:

  <application android:allowNativeHeapPointerTagging="false">
  ...
  </application>

as a workaround, for now, disable the NDK integration.

https://docs.sentry.io/platforms/android/#configuration-options

eg:

<application>
    <meta-data android:name="io.sentry.ndk.enable" android:value="false" />
</application>

Having a similar issue on Pixel 4XL as well. Seeing this error log whenever I run my app:

2020-09-10 14:58:36.005 30419-30419 D/Sentry: Auto-init: false
2020-09-10 14:58:36.005 30419-30419 I/Sentry: Retrieving auto-init from AndroidManifest.xml
2020-09-10 14:58:36.169 30419-30520 I/Sentry: sentry-debug-meta.properties file was not found.
2020-09-10 14:58:36.188 30419-30520 D/Sentry: SU doesn't exist.
    java.io.IOException: Cannot run program "/system/xbin/which": error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
        at java.lang.Runtime.exec(Runtime.java:699)
        at java.lang.Runtime.exec(Runtime.java:564)
        at io.sentry.android.core.util.RootChecker.checkSUExist(RootChecker.java:135)
        at io.sentry.android.core.util.RootChecker.isDeviceRooted(RootChecker.java:90)
        at io.sentry.android.core.DefaultAndroidEventProcessor.loadContextData(DefaultAndroidEventProcessor.java:114)
        at io.sentry.android.core.DefaultAndroidEventProcessor.lambda$new$0$DefaultAndroidEventProcessor(DefaultAndroidEventProcessor.java:102)
        at io.sentry.android.core.-$$Lambda$DefaultAndroidEventProcessor$ZsPdDrAaOs30gov_5eSNgy_KYe8.call(Unknown Source:2)
        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:923)
     Caused by: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
        at java.lang.ProcessImpl.start(ProcessImpl.java:141)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        at java.lang.Runtime.exec(Runtime.java:699) 
        at java.lang.Runtime.exec(Runtime.java:564) 
        at io.sentry.android.core.util.RootChecker.checkSUExist(RootChecker.java:135) 
        at io.sentry.android.core.util.RootChecker.isDeviceRooted(RootChecker.java:90) 
        at io.sentry.android.core.DefaultAndroidEventProcessor.loadContextData(DefaultAndroidEventProcessor.java:114) 
        at io.sentry.android.core.DefaultAndroidEventProcessor.lambda$new$0$DefaultAndroidEventProcessor(DefaultAndroidEventProcessor.java:102) 
        at io.sentry.android.core.-$$Lambda$DefaultAndroidEventProcessor$ZsPdDrAaOs30gov_5eSNgy_KYe8.call(Unknown Source:2) 
        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:923) 

Originally I suspected an error with Android’s new Wireless ADB feature that I was trying, but even plugging the phone in manually didn’t work.

I’m able to run on a Pixel 3a emulator with Android 11 just fine.

EDIT: I see the same thing in the logs when I run on a Pixel 3 XL, but it does not crash on startup. So maybe those logs are a red herring, but definitely something fishy going on with the Pixel 4 line.

this is just a debug log though, we run some code to see if the device is rooted or not and if not, we log it, this only appears if you run on debug mode, it’s not a bug. this issue is about a crash on startup using Pixel 4 and Android 11.

The sentry version is 2.3.2

These devices has android 11installed and causes crash when sentry is installed

On which version of sentry-android is that? It seems the the original issue was resolved though, so please raise a new issue and fill out the issue template.

please upgrade to the min. version 3.1.0 and see if that fixes the problem before raising a new issue, it’s likely solving it.

The issue has been fixed when using sentry-android v 4.1.0 Thanks of the support 👍

Confirming that both of @marandaneto’s mentioned workarounds seem to work on a physical Pixel 4 running Android 11.

  <application android:allowNativeHeapPointerTagging="false">
  ...
  </application>

or

<application>
    <meta-data android:name="io.sentry.ndk.enable" android:value="false" />
</application>

So I just ran our android example through a debugger on a freshly patched Pixel 4.

https://github.com/getsentry/sentry-native/blob/425b803d53acc2d598633fd64ac969508487007e/src/sentry_value.c#L199

This malloc gives me 0xb400007bda776d90, after NaN-boxing, we end up with 0x0000007bda776d90, and according to the documented linked above:

Any application that modifies this tag is terminated when the tag is checked during deallocation.

Using android:allowNativeHeapPointerTagging="false" as workaround works for me. Getting rid of the NaN-boxing in sentry-native would be quite some work, but I suspect that we already ran into problems with it with a different native customer, though I’m not sure.

@marandaneto I implemented your workaround with disabling the NDK and was able to run my application on my Pixel 4. Are there any consequences to turning this off in terms of errors not being reported to Sentry or something like that?

Checking out the project now to run the latest main branch.

you basically won’t get any Native crashes (NDK C/C++) reports on Sentry, if your App is just written in Java/Kotlin, it won’t be a big issue, thanks for confirming the workaround.

Having a similar issue on Pixel 4XL as well. Seeing this error log whenever I run my app:

// EDIT: Removed these logs that weren't actually relevant because I don't want to clutter the ticket & confuse people. 

Originally I suspected an error with Android’s new Wireless ADB feature that I was trying, but even plugging the phone in manually didn’t work.

I’m able to run on a Pixel 3a emulator with Android 11 just fine.

EDIT: I see the same thing in the logs when I run on a Pixel 3 XL, but it does not crash on startup. So maybe those logs are a red herring, but definitely something fishy going on with the Pixel 4 line.