Skip to content

App crashes related to JNI's AttachToCurrentThread #7623

Closed

Description

@grendello

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

All

Description

Native crashes reported by Google Play:

SIGABRT on Android 9

/__w/1/s/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/pal_jni.c:621 (GetJNIEnv): Unable to attach thread to JVM
#00  pc 0x000000000001cf76  /system/lib/libc.so (abort+58)
#01  pc 0x0000000000008b7b  /data/app/com.sequrix.app-IAFmw0oXJlue17PBOBPjYw==/lib/arm/libSystem.Security.Cryptography.Native.Android.so
#02  pc 0x0000000000008cd9  /data/app/com.sequrix.app-IAFmw0oXJlue17PBOBPjYw==/lib/arm/libSystem.Security.Cryptography.Native.Android.so
#03  pc 0x0000000000010747  /data/app/com.sequrix.app-IAFmw0oXJlue17PBOBPjYw==/lib/arm/libSystem.Security.Cryptography.Native.Android.so (AndroidCryptoNative_SSLStreamWrite+58)

SIGSEGV on Android 8

#00  pc 0x000000000001cbe0  /system/lib64/libc.so (strlen+16)
#01  pc 0x0000000000461040  /system/lib64/libart.so (art::Thread::Attach(char const, bool, _jobject, bool)+196)
#02  pc 0x000000000043d84c  /system/lib64/libart.so (art::Runtime::AttachCurrentThread(char const, bool, _jobject, bool)+84)
#03  pc 0x00000000002de424  /system/lib64/libart.so (art::JII::AttachCurrentThreadInternal(_JavaVM, _JNIEnv**, void, bool)+268)
#04  pc 0x000000000002164c  /data/app/com.sequrix.app-QbvZn4-G-Erqd6bOwoeXpA==/lib/arm64/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::thread_start(_MonoProfiler, unsigned long)+56)
#05  pc 0x00000000000ab44c  /data/app/com.sequrix.app-QbvZn4-G-Erqd6bOwoeXpA==/lib/arm64/libmonosgen-2.0.so
#06  pc 0x00000000000b2640  /data/app/com.sequrix.app-QbvZn4-G-Erqd6bOwoeXpA==/lib/arm64/libmonosgen-2.0.so
#07  pc 0x00000000000b2390  /data/app/com.sequrix.app-QbvZn4-G-Erqd6bOwoeXpA==/lib/arm64/libmonosgen-2.0.so
#08  pc 0x0000000000066f34  /system/lib64/libc.so (__pthread_start(void)+36)
#09  pc 0x000000000001eb94  /system/lib64/libc.so (__start_thread+68)

Relevant information gathered from Discord.

SIGABRT due to abort() call here. Error unknown as of now.

SIGSEGV might be caused by invalid pointer passed to AttachCurrentThread, as its 2nd argument. Xamarin.Android passes nullptr there (as allowed by the API, it's a valid input), so the pointer should be correctly ignored by the Java/JNI code, and yet it crashes somewhere in here. strlen in the stack trace suggests one of the LOG statements referring to thread_name which might be the pointer with garbage data?

Steps to Reproduce

None so far

Did you find any workaround?

Nope

Relevant log output

No response

Activity

  1. added
    Area: App Runtime
    needs-triage
    on Dec 8, 2022
  2. self-assigned this
    on Dec 8, 2022
  3. removed
    needs-triage
    on Dec 8, 2022
  4. added this to the Under Consideration milestone on Dec 8, 2022
  5. removed their assignment
    on Mar 26, 2026
  6. added
    possibly-stale
    on Aug 7, 2026
  7. dotnet-policy-service commented on Aug 7, 2026

    @dotnet-policy-service

    We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

  8. dotnet-policy-service commented on Aug 21, 2026

    @dotnet-policy-service

    This issue will now be closed since it had been marked "possibly-stale" but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  9. locked and limited conversation to collaborators on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App Runtimepossibly-stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions