Repository navigation
Description
Description
On iOS (New Architecture, bridgeless), an app crashes with EXC_BAD_ACCESS on the old instance's JS thread when it reloads its React instance while that instance is still committing UI updates. In our case the reload is expo-updates' Updates.reloadAsync() right after an update is downloaded at launch, while the app is still mounting its first screens. Anything that tears down RCTHost/RCTInstance this way is affected (dev reload, OTA reload).
Root cause. Scheduler queues rendering updates on RuntimeScheduler_Modern that capture the SchedulerDelegate as a raw pointer:
Scheduler::uiManagerDidFinishTransaction→delegate->schedulerShouldRenderTransactions(...)Scheduler::uiManagerDidDispatchCommand→delegate->schedulerDidDispatchCommand(...)Scheduler::uiManagerDidFinishReactCommit→delegate->schedulerShouldMergeReactRevision(...)
On iOS the delegate is SchedulerDelegateProxy, owned by RCTScheduler (std::unique_ptr<SchedulerDelegateProxy> _delegateProxy). During teardown -[RCTScheduler dealloc] calls _scheduler->setDelegate(nullptr) on the main thread and then frees the proxy. Meanwhile the old instance's JS thread can still be in runEventLoopTick. At the end of the tick, updateRendering() drains pendingRenderingUpdates_, and the lambda calls a virtual method through the freed proxy.
This is the window that #58138 (removing enableSchedulerDelegateInvalidation) describes as still open: a delegate detached with no error never reaches handleTaskError, so nothing clears the queue. SchedulerDelegateInvalidationTest's DelegateDetachedWithoutError_PendingRenderingUpdateCallsStaleDelegate pins it. This issue shows that window being hit in production, through a plain reload with no JS error.
Steps to reproduce
The race is timing dependent, so there is no deterministic repro in an app. The conditions:
- iOS, New Architecture (bridgeless), RN 0.88.1. The code is unchanged on
main. - Have the app commit continuously (e.g. mount a large tree and load data) while calling a reload:
Updates.reloadAsync()fromexpo-updates, orDevSettings.reload(). - Sometimes the old instance's JS thread crashes as below.
Deterministic repro at the unit level: in SchedulerDelegateInvalidationTest, enqueue a transaction, call setDelegate(nullptr), then drain one tick. The queued lambda still calls the detached delegate (see the existing Test 3).
React Native Version
0.88.1
Affected Platforms
Runtime - iOS
Areas
Fabric - The New Renderer, Bridgeless - The New Initialization Flow
Output of npx @react-native-community/cli info
React Native 0.88.1, Expo SDK 58, Hermes, New Architecture (bridgeless). Release build from the App Store, iOS 27.2.1, iPhone 11 Pro (iPhone12,3).
Stacktrace or Logs
EXC_BAD_ACCESS / SIGSEGV: KERN_INVALID_ADDRESS at 0x9b3e6f6895d8472d
x9 = 0x9b3e6f6895d84725 (fault address = x9 + 8: a vtable slot loaded through freed memory)
Thread 11 Crashed: com.facebook.react.runtime.JavaScript (old instance)
0 React std::__1::__function::__func<...>::operator() <- queued rendering update lambda
1 React facebook::react::RuntimeScheduler_Modern::runEventLoopTick
2 React facebook::react::RuntimeScheduler_Modern::runEventLoop
3 React std::__1::__function::__func<...>::operator()
4 React facebook::react::tryAndReturnError
5 React std::__1::__function::__func<...>::operator()
6 React facebook::react::RCTMessageThread::runAsync
7 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
...
10 React +[RCTJSThreadManager runRunLoop]
Thread 22: (new instance, already running JS)
0 hermesvm hermes::vm::Interpreter::interpretFunction
...
React facebook::react::Task::execute
React facebook::react::RuntimeScheduler_Modern::executeTask
React facebook::react::RuntimeScheduler_Modern::runEventLoopTick
...
React +[RCTJSThreadManager runRunLoop]
Two React instances were alive at the time of the crash: two JS threads running RCTJSThreadManager runRunLoop, and two sets of Hermes HadesGC and SerialExecutor threads. The crash came about 2 s after app start, right after the app called reloadAsync().
MANDATORY Reproducer
The race can't be shown deterministically in an app (see Steps). The unit-level reproduction is the existing SchedulerDelegateInvalidationTest (Test 3). The linked PR turns it into a regression test and adds tests for a detach that happens while a queued update is calling the delegate.
Screenshots and Videos
No response
Activity
react-native-bot commentedon Nov 27, 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.
Fix use-after-free of SchedulerDelegate in queued rendering updates
Fix use-after-free of SchedulerDelegate in queued rendering updates
yspreen commentedon Nov 27, 2026
About the reproducer: this is a teardown race, and I don't have an app that hits it on demand. I tried a fresh project from the reproducer template on 0.88.1, Release build on an iOS 27.2 simulator: a grid that re-renders every frame,
scrollTocommands from inside and outside React's lifecycle, and a native reload (RCTTriggerReloadCommandListeners) every 50-400 ms. It survived about 4,600 reloads, including 1,175 withMallocScribble=1. The trace in the report comes from a production app (one occurrence so far, iPhone 11 Pro, iOS 27.2.1): the crash came 2 s after launch, right afterexpo-updates'reloadAsync().The reproduction that is deterministic is at the unit level, and it is already in the repo:
SchedulerDelegateInvalidationTest'sDelegateDetachedWithoutError_PendingRenderingUpdateCallsStaleDelegate(added with #58138). It shows a queued rendering update calling a detached delegate when no JS error is involved. On iOS,-[RCTScheduler dealloc]frees that delegate (SchedulerDelegateProxy) right aftersetDelegate(nullptr), which turns that call into the use-after-free in the stack trace above.#60325 fixes it and turns that test into a regression test. Its test plan shows the tests failing without the fix.
nbushak commentedon Dec 1, 2026
We hit this too on RN 0.88.1 / Expo SDK 58 (bridgeless, Hermes), and our app reproduces it on demand, though we also don't have a minimal project:
DevSettings.reload()) every 2–4 seconds.We're applying this guard (essentially #56680 with a token per delegate), through patch-package with
ios.buildReactNativeFromSourceso it compiles:With it, 40 reloads during streaming (29 logged
Schedulerteardowns) didn't crash. In 0.88.1 theuiManagerDidFinishReactCommitupdate doesn't capture the delegate: it readsdelegate_when it runs, sosetDelegate(nullptr)already covers it.This narrows the race but doesn't close it: the old JS thread can pass the flag check just before the main thread frees
SchedulerDelegateProxy. A complete fix probably needs the queued work to keep the delegate alive (or check a weak owner), or teardown to wait for the old JS thread to drain.nazmiaydogdu commentedon Dec 4, 2026
We get the same crash when iOS terminates the app (RN 0.88.1, bridgeless).
RCTSurfacePresenter._applicationWillTerminatecallssuspend, which drops the delegate with no error: the open window described in #58138.