Repository navigation
Description
Note
This issue was authored by AI on behalf of @tjzel.
Description
ThreadSanitizer reports a data race on a facebook::react::Task between the JS thread and a Hermes SerialExecutor thread (report below). The write is Task::execute resetting callback on the JS thread (ReactCommon/react/renderer/runtimescheduler/Task.cpp:50). The read is the Task destructor (__shared_ptr_emplace<Task>::__on_zero_shared) on a thread that Hermes starts from hermes::SerialExecutor::add, when the last shared_ptr<jsi::NativeState> to the task is released (Task is a jsi::NativeState, Task.h:30).
This is most likely a false positive, and I am filing it so it can be tracked and confirmed. The final reference count decrement happens inside hermesvm, which in this build is the prebuilt framework and is not instrumented by ThreadSanitizer. TSAN therefore cannot see the acquire on that decrement, and so it misses the happens-before edge from the JS thread's writes to the destructor. The scheduler keeps its own shared_ptr<Task> while the task runs (RuntimeScheduler_Modern::runEventLoop, RuntimeScheduler_Modern.cpp:285-287), so the destructor cannot run concurrently with Task::execute as far as I can tell. I have not verified this with an instrumented Hermes build.
Questions for maintainers:
- Is there a supported way to build Hermes with ThreadSanitizer for iOS apps (e.g. a from-source
hermes-enginepod with-fsanitize=thread), so this can be confirmed or ruled out? - If it is a known false positive, could it be documented, or a TSAN suppression shipped, so downstream projects running sanitizers do not each rediscover it?
The report is intermittent: it appeared in 2 of 3 local runs of our suite.
Steps to reproduce
git clone https://github.com/software-mansion/react-native-reanimated.git && cd react-native-reanimated && git checkout dc0165fc5636b20d7c0b38f8b06019934ff4fa28 && yarncd apps/fabric-example/ios && RCT_USE_PREBUILT_RNCORE=0 RCT_USE_RN_DEP=0 bundle exec pod install && cd ../../..(React Native core from source and instrumented; Hermes stays the prebuilt framework)yarn workspace fabric-example runtime-tests --library reanimated --platform ios --udid <simulator udid> --configuration ReleaseRuntimeTests --sanitizer thread- Read
apps/fabric-example/sanitizer-reports/tsan.*.
React Native Version
0.88.0
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 27.2.1
CPU: (14) arm64 Apple M4 Pro
Binaries:
Node:
version: 22.14.0
Yarn:
version: 4.13.0
Managers:
CocoaPods:
version: 1.16.2
SDKs:
iOS SDK:
Platforms:
- iOS 27.2
IDEs:
Xcode:
version: 27.2/27B52
npmPackages:
react-native: 0.88.0
Stacktrace or Logs
Frames in FabricExample symbolized with atos against the build: #0 of the read is shared_ptr.h:183 (__on_zero_shared), #0 of the write is Task.cpp:50, then RuntimeScheduler_Modern.cpp:420 (executeTask), :333 (runEventLoopTick), :287 (runEventLoop).
ThreadSanitizer report
==================
WARNING: ThreadSanitizer: data race (pid=68874)
Read of size 1 at 0x00010d7a4d20 by thread T14:
#0 std::__1::__shared_ptr_emplace<facebook::react::Task, std::__1::allocator<facebook::react::Task>>::__on_zero_shared() <null> (FabricExample:arm64+0x100849874)
#1 std::__1::shared_ptr<facebook::jsi::NativeState>::~shared_ptr[abi:ne190102]() <null> (hermesvm:arm64+0x36248)
Previous write of size 1 at 0x00010d7a4d20 by thread T8:
#0 facebook::react::Task::execute(facebook::jsi::Runtime&, bool) <null> (FabricExample:arm64+0x100850be4)
#1 facebook::react::RuntimeScheduler_Modern::executeTask(facebook::jsi::Runtime&, facebook::react::Task&, bool) <null> (FabricExample:arm64+0x100847870)
#2 facebook::react::RuntimeScheduler_Modern::runEventLoopTick(facebook::jsi::Runtime&, facebook::react::Task&) <null> (FabricExample:arm64+0x100848414)
#3 facebook::react::RuntimeScheduler_Modern::runEventLoop(facebook::jsi::Runtime&) <null> (FabricExample:arm64+0x100848008)
#4 std::__1::__function::__func<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) <null> (FabricExample:arm64+0x10084bf84)
#5 _ZNSt3__110__function6__funcIZZN8facebook5react13ReactInstanceC1ENS_10unique_ptrINS3_9JSRuntimeENS_14default_deleteIS6_EEEENS_10shared_ptrINS3_18MessageQueueThreadEEENSA_INS3_12TimerManagerEEENS_8functionIFvRNS2_3jsi7RuntimeERKNS3_14JsErrorHandler14ProcessedErrorEEEEPNS3_18jsinspector_modern10HostTargetEENK3$_0clINSF_IFvSI_EEEEEDaT_EUlvE_FvvEEclEv <null> (FabricExample:arm64+0x1007a19bc)
#6 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) <null> (FabricExample:arm64+0x100468908)
#7 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) <null> (FabricExample:arm64+0x10047cde4)
#8 std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0, void ()>::operator()() <null> (FabricExample:arm64+0x10047dd3c)
#9 invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) <null> (FabricExample:arm64+0x10047ca5c)
#10 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ <null> (CoreFoundation:arm64+0x93d24)
#11 __NSThread__start__ <null> (Foundation:arm64+0x914ed8)
Location is heap block of size 104 at 0x00010d7a4cd0 allocated by thread T8:
#0 operator new(unsigned long) <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x89188)
#1 std::__1::shared_ptr<facebook::react::Task> std::__1::allocate_shared[abi:nqe220106]<facebook::react::Task, std::__1::allocator<facebook::react::Task>, facebook::react::SchedulerPriority&, facebook::jsi::Function, facebook::react::HighResTimeStamp&, 0>(std::__1::allocator<facebook::react::Task> const&, facebook::react::SchedulerPriority&, facebook::jsi::Function&&, facebook::react::HighResTimeStamp&) <null> (FabricExample:arm64+0x10084969c)
#2 facebook::react::RuntimeScheduler_Modern::scheduleTask(facebook::react::SchedulerPriority, facebook::jsi::Function&&) <null> (FabricExample:arm64+0x100846e74)
#3 facebook::react::RuntimeScheduler::scheduleTask(facebook::react::SchedulerPriority, facebook::jsi::Function&&) <null> (FabricExample:arm64+0x100845b20)
#4 std::__1::__function::__func<facebook::react::RuntimeSchedulerBinding::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::$_0, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) <null> (FabricExample:arm64+0x10084e980)
#5 std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const <null> (hermesvm:arm64+0x36c50)
#6 facebook::react::RuntimeScheduler_Modern::runEventLoopTick(facebook::jsi::Runtime&, facebook::react::Task&) <null> (FabricExample:arm64+0x100848420)
#7 facebook::react::RuntimeScheduler_Modern::runEventLoop(facebook::jsi::Runtime&) <null> (FabricExample:arm64+0x100848008)
#8 std::__1::__function::__func<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) <null> (FabricExample:arm64+0x10084bf84)
#9 _ZNSt3__110__function6__funcIZZN8facebook5react13ReactInstanceC1ENS_10unique_ptrINS3_9JSRuntimeENS_14default_deleteIS6_EEEENS_10shared_ptrINS3_18MessageQueueThreadEEENSA_INS3_12TimerManagerEEENS_8functionIFvRNS2_3jsi7RuntimeERKNS3_14JsErrorHandler14ProcessedErrorEEEEPNS3_18jsinspector_modern10HostTargetEENK3$_0clINSF_IFvSI_EEEEEDaT_EUlvE_FvvEEclEv <null> (FabricExample:arm64+0x1007a19bc)
#10 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) <null> (FabricExample:arm64+0x100468908)
#11 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) <null> (FabricExample:arm64+0x10047cde4)
#12 std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0, void ()>::operator()() <null> (FabricExample:arm64+0x10047dd3c)
#13 invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) <null> (FabricExample:arm64+0x10047ca5c)
#14 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ <null> (CoreFoundation:arm64+0x93d24)
#15 __NSThread__start__ <null> (Foundation:arm64+0x914ed8)
Thread T14 (tid=1257374, running) created by thread T8 at:
#0 pthread_create <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x30308)
#1 hermes::SerialExecutor::add(llvh::unique_function<void ()>) <null> (hermesvm:arm64+0x15fce8)
#2 facebook::react::Task::execute(facebook::jsi::Runtime&, bool) <null> (FabricExample:arm64+0x100850cb4)
#3 facebook::react::RuntimeScheduler_Modern::executeTask(facebook::jsi::Runtime&, facebook::react::Task&, bool) <null> (FabricExample:arm64+0x100847870)
#4 facebook::react::RuntimeScheduler_Modern::runEventLoopTick(facebook::jsi::Runtime&, facebook::react::Task&) <null> (FabricExample:arm64+0x100848414)
#5 facebook::react::RuntimeScheduler_Modern::runEventLoop(facebook::jsi::Runtime&) <null> (FabricExample:arm64+0x100848008)
#6 std::__1::__function::__func<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) <null> (FabricExample:arm64+0x10084bf84)
#7 _ZNSt3__110__function6__funcIZZN8facebook5react13ReactInstanceC1ENS_10unique_ptrINS3_9JSRuntimeENS_14default_deleteIS6_EEEENS_10shared_ptrINS3_18MessageQueueThreadEEENSA_INS3_12TimerManagerEEENS_8functionIFvRNS2_3jsi7RuntimeERKNS3_14JsErrorHandler14ProcessedErrorEEEEPNS3_18jsinspector_modern10HostTargetEENK3$_0clINSF_IFvSI_EEEEEDaT_EUlvE_FvvEEclEv <null> (FabricExample:arm64+0x1007a19bc)
#8 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) <null> (FabricExample:arm64+0x100468908)
#9 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) <null> (FabricExample:arm64+0x10047cde4)
#10 std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0, void ()>::operator()() <null> (FabricExample:arm64+0x10047dd3c)
#11 invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) <null> (FabricExample:arm64+0x10047ca5c)
#12 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ <null> (CoreFoundation:arm64+0x93d24)
#13 __NSThread__start__ <null> (Foundation:arm64+0x914ed8)
Thread T8 (tid=1257357, running) created by main thread at:
#0 pthread_create <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x30308)
#1 -[NSThread startAndReturnError:] <null> (Foundation:arm64+0x914b24)
#2 -[RCTJSThreadManager init] <null> (FabricExample:arm64+0x10079817c)
#3 -[RCTInstance initWithDelegate:jsRuntimeFactory:bundleManager:turboModuleManagerDelegate:moduleRegistry:parentInspectorTarget:launchOptions:devMenuConfiguration:] <null> (FabricExample:arm64+0x1007902d8)
#4 -[RCTHost start] <null> (FabricExample:arm64+0x10078c3f4)
#5 -[RCTRootViewFactory createReactHost:bundleConfiguration:devMenuConfiguration:] <null> (FabricExample:arm64+0x1006b8e8c)
#6 -[RCTRootViewFactory createReactHostIfNeeded:bundleConfiguration:devMenuConfiguration:] <null> (FabricExample:arm64+0x1006b8b40)
#7 -[RCTRootViewFactory initializeReactHostWithLaunchOptions:bundleConfiguration:devMenuConfiguration:] <null> (FabricExample:arm64+0x1006b8710)
#8 -[RCTRootViewFactory viewWithModuleName:initialProperties:launchOptions:bundleConfiguration:devMenuConfiguration:] <null> (FabricExample:arm64+0x1006b8918)
#9 -[RCTReactNativeFactory startReactNativeWithModuleName:inWindow:initialProperties:launchOptions:] <null> (FabricExample:arm64+0x1006b5764)
#10 -[RCTReactNativeFactory startReactNativeWithModuleName:inWindow:initialProperties:connectionOptions:] <null> (FabricExample:arm64+0x1006b5cdc)
#11 specialized SceneDelegate.scene(_:willConnectTo:options:) <null> (FabricExample:arm64+0x100006ff8)
#12 @objc SceneDelegate.scene(_:willConnectTo:options:) <null> (FabricExample:arm64+0x100005e44)
#13 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] <null> (UIKitCore:arm64+0x53363c)
#14 start_sim <null> (dyld_sim:arm64+0xb0e0)
SUMMARY: ThreadSanitizer: data race (FabricExample:arm64+0x100849874) in std::__1::__shared_ptr_emplace<facebook::react::Task, std::__1::allocator<facebook::react::Task>>::__on_zero_shared()+0x1c
MANDATORY Reproducer
https://github.com/software-mansion/react-native-reanimated/tree/dc0165fc5636b20d7c0b38f8b06019934ff4fa28 (steps above; the test driver is apps/fabric-example/scripts/runtime-tests-server.mts)
Screenshots and Videos
No response
Activity
react-native-bot commentedon Nov 18, 2026
Warning
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
You can read more about about it on our website: How to report a bug.