[Android] SIGSEGV in executeLayoutAnimationsRequests: performOperations races invalidateCpp at ReactHost teardown (null ReanimatedModuleProxy)
[!NOTE] This issue was authored by AI on behalf of @mikelros.
Description
We received a production SIGSEGV (Android, release build) with this stack trace:
SIGSEGV: Segfault
at facebook::jni::detail::FunctionWrapper<T>::call (Registration-inl.h:95)
at facebook::jni::detail::CallWithJniConversions<T>::call (Registration-inl.h:66)
at facebook::jni::detail::MethodWrapper<T>::dispatch (Registration-inl.h:129)
at reanimated::NativeProxy::performOperations (NativeProxy.cpp:133)
reanimatedModuleProxy_->performOperations();
at reanimated::ReanimatedModuleProxy::performOperations (ReanimatedModuleProxy.cpp:770)
executeLayoutAnimationsRequests();
at reanimated::ReanimatedModuleProxy::executeLayoutAnimationsRequests (ReanimatedModuleProxy.cpp:754)
std::set<SurfaceId> flushRequestsCopy = std::move(layoutAnimationFlushRequests_);
at std::__ndk1::set<T>::set[abi:ne180000] (set:661)
at std::__ndk1::__tree<T>::__tree (__tree:1455)
: __begin_node_(std::move(__t.__begin_node_)),The fault happens on the first member-memory read after the call enters ReanimatedModuleProxy::performOperations (the move of layoutAnimationFlushRequests_). The move constructor of std::__tree only copies three pointers, so a fault there means the object pointer itself is invalid — reanimatedModuleProxy_ was null or dangling when NativeProxy::performOperations dereferenced it.
Code-path analysis (why the pointer is null)
The code below is from 4.5.3, but main has the same unguarded call today.
NativeProxy::invalidateCpp()resets the shared pointer, but the JNIHybridDatastays valid, so later JNI calls still dispatch into the liveNativeProxyobject:// NativeProxy.cpp void NativeProxy::invalidateCpp() { uiRuntime_.reset(); reanimatedModuleProxy_->cleanupSensors(); reanimatedModuleProxy_.reset(); // <- pointer becomes null javaPart_ = nullptr; }React Native calls
ReanimatedModule.invalidate()→NodesManager.invalidate()during ReactHost teardown, on the NativeModules thread, not on the UI thread:// NodesManager.kt fun invalidate() { mNativeProxy?.let { it.invalidate() // resets reanimatedModuleProxy_ (off the UI thread) mNativeProxy = null } ... }Concurrently, a queued Choreographer frame on the UI thread runs:
// NodesManager.kt fun performOperations() { UiThreadUtil.assertOnUiThread() mNativeProxy?.performOperations() // null check can pass before step 2 nulls the field }The JNI call then executes
reanimatedModuleProxy_->performOperations()(NativeProxy.cpp:133) on a null shared pointer. The first member access is the set move at ReanimatedModuleProxy.cpp:754, which faults with a near-null address. That is exactly the observed stack.
mHybridData.isValid does not protect this path: invalidateCpp does not reset the HybridData, only the inner shared pointer.
Expected behavior
performOperations must not dereference reanimatedModuleProxy_ after invalidateCpp ran. Possible fixes:
- Null-guard
reanimatedModuleProxy_(andperformNonLayoutOperations) inNativeProxy, or - Null
mNativeProxy/ stop the Choreographer callback on the UI thread beforeinvalidateCppruns, so no frame can slip through the window.
Occurrence details
- One production event so far (2026-08-13). The window is a few instructions wide, so the volume is very low, but the crash is deterministic once the interleaving happens.
- Device: POCO 25102PCBEG (Xiaomi, SM8850), Android 16, arm64-v8a, real device, not rooted, installed from Play Store.
- App: React Native 0.86.2 (New Architecture), Hermes, Expo SDK 57 (bare / dev-client workflow), release build with a production bundle, expo-updates enabled.
Steps to reproduce
- Run any app with an active Reanimated animation, so a Choreographer frame callback is queued.
- Destroy the React instance (ReactHost teardown / reload) so
ReanimatedModule.invalidate()runs on the NativeModules thread. - If the queued UI-thread frame passes the
mNativeProxynull check beforeinvalidatenulls it, andinvalidateCppresets the shared pointer before the JNI call dereferences it, the process faults.
Snack or a link to a repository
Not reproducible on demand — this is a teardown race with a window of a few instructions. The code-path analysis above identifies the exact interleaving. We can confirm the window with an injected-delay build of invalidateCpp if that helps.
Reanimated version
4.5.3
Worklets version
0.11.3
React Native version
0.86.2
Platforms
Android
JavaScript runtime
Hermes
Workflow
Expo Dev Client (bare workflow)
Architecture
New Architecture (Fabric renderer)
Reanimated feature flags
No
React Native release level
Stable
Build type
Release app & production bundle
Device
Real device
Host machine
macOS
Device model
POCO 25102PCBEG, Android 16
Acknowledgements
Yes — I searched for similar issues (#9402 and #8150 are different performOperations crashes on iOS / older versions).
Source: software-mansion/react-native-reanimated