Repository navigation
Description
Description
On Android, a crash that lands while the native SDK is being closed deadlocks the process instead of producing a crash report. The crashing thread blocks inside the signal handler in read(). The platform thread blocks in sentry_close() → pthread_join(). Neither returns: no tombstone, no Sentry event, the UI freezes, and Android reports an ANR 80 s later.
The close comes from a re-init: a Flutter engine was recreated in the same process, its Dart main() called SentryFlutter.init again, and SentryAndroid.init closed the previous Scopes, which closes the NDK integration.
Environment
sentry_flutter9.30.0, which bringsio.sentry:sentry-android8.56.0 and its bundledlibsentry.so- NDK integration on (the default)
- Pixel 8 (Tensor G3, Mali GPU), Android 16
- Flutter 3.47.3, profile build
Steps to reproduce
This needs a native crash at the moment the native SDK closes, so it is a race. We hit it once in two tries and not again in 28 more.
- A Flutter app that calls
SentryFlutter.initinmain(), with a plainFlutterActivity. - Change a configuration that recreates the activity, for example the system navigation mode. The default
FlutterActivitydestroys its engine and creates a new one in the same process, somain()andSentryFlutter.initrun a second time. - The old engine's GPU teardown aborts on another thread in that window (
FORTIFY: pthread_mutex_lock called on a destroyed mutexin the Mali Vulkan driver; that half is a Flutter bug, reported in [Impeller] SIGABRT in vkDestroyFramebuffer after long background dwell (cross-GPU: Mali + Adreno) flutter/flutter#191168).
Expected
The abort is captured, or at worst the process dies with a tombstone.
Actual
The process hangs. From the ANR trace (package path removed):
Platform thread, in the second init:
"main" prio=5 tid=1 Native
#00 libc.so syscall+32
#01 libc.so pthread_join+240
#02 libsentry.so (???)
#03 libsentry.so sentry_close+128
at io.sentry.ndk.SentryNdk.shutdown(Native method)
at io.sentry.ndk.SentryNdk.close(SentryNdk.java:61)
at io.sentry.android.ndk.SentryNdk.close(SentryNdk.java:102)
at io.sentry.android.core.NdkIntegration.close(NdkIntegration.java:90)
at io.sentry.Scopes.close(Scopes.java:442)
at io.sentry.Sentry.init(Sentry.java:344)
at io.sentry.Sentry.init(Sentry.java:251)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:103)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:84)
The crashing thread, inside the signal handler:
"Thread-73" prio=5 tid=36 Native
#00 libc.so read+8
#01 libsentry.so (???)
#02 libsentry.so (???)
#03 [vdso]
#04 libc.so __fortify_fatal+224
#05 libc.so HandleUsingDestroyedMutex+64
#06 libc.so pthread_mutex_lock+140
#07 libGLES_mali.so vulkan::device::remove_slot_data+32
#08 libGLES_mali.so vkDestroyRenderPass+72
#09.. libflutter.so
A third thread waits on a mutex in sentry_add_breadcrumb:
"SentryExecutorServiceThreadFactory-0" daemon prio=5 tid=61 Native
#00 libc.so syscall+32
#01 libc.so __futex_wait_ex+132
#02 libc.so NonPI::MutexLockWithTimeout+528
#03 libsentry.so sentry_add_breadcrumb+88
at io.sentry.ndk.NativeScope.nativeAddBreadcrumb(Native method)
at io.sentry.ndk.NativeScope.addBreadcrumb(NativeScope.java:68)
at io.sentry.android.ndk.NdkScopeObserver.lambda$addBreadcrumb$1...
These are the only three threads in the dump with libsentry.so frames. The thread that sentry_close joins does not appear in the dump, so I cannot show what it was waiting on. My reading is that the handler on tid 36 waits for a reply over a pipe from a thread that sentry_close is shutting down, but that is inference.
Workaround
We stopped the engine re-creation on a configuration change, so SentryFlutter.init no longer runs twice in one process on that path. The window still exists for any app that re-initialises the SDK while another thread can crash.
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Oct 23, 2026
NATIVE-239
jpnurmi commentedon Oct 26, 2026
Thanks for a detailed report!
ref: remove options lock from sentry_envelope
fix(inproc): remove options lock from the handler thread
ref: guard the current session with a session lock
ref: remove options lock from session updates
fix(inproc): remove options lock from the handler thread
ref: remove options lock from sentry_envelope
ref: guard the current session with a session lock
ref: remove options lock from session updates
fix(inproc): remove options lock from the handler thread
ref: remove options lock from sentry_envelope (#2248)
ref: remove options lock from session updates (#2249)
fix(inproc): remove options lock from the handler thread (#2252)