Repository navigation
Description
Description
This is a re-file of #58299, which was closed by the bot for a missing template and reproducer, with a ThreadSanitizer reproduction and a narrower fix.
-[RCTComponentViewFactory _registerComponentIfPossible:] runs on the JS thread, through the ComponentDescriptorProviderRegistry request callback. Its Fallback 3 (legacy interop) and Fallback 4 (UnimplementedView) write _componentViewClasses and _registrationStatusMap without taking _mutex. Its initial _registrationStatusMap.find and -_wasComponentRegistered: also read without it.
On the main thread, -createComponentViewWithComponentHandle: holds only std::shared_lock lock(_mutex) while it calls _componentViewClasses.find(handle). A concurrent unlocked insert can make that lookup miss a long-registered handle. In our crash reports the missed handle is the built-in Paragraph. A Debug build then aborts with:
RCTAssert: ComponentView with componentHandle `…` (`Paragraph`) not found.
In Release the assert compiles out and the end() iterator is dereferenced. #58299 shows a production SIGSEGV at fault address 0x18.
Any app that renders a component through the legacy interop layer is exposed. That includes a library without Fabric codegen (MapLibre RN 10.x's MLRN* views, for example), RNCMaskedView, and any host name that resolves to UnimplementedView. The first render of each such name is a writer.
ThreadSanitizer report. Taken from a source build of React Native 0.88.1 on the iOS 27.2 simulator, with TSan enabled on RCTComponentViewFactory.mm only. Internal std::unordered_map frames are trimmed:
WARNING: ThreadSanitizer: data race
Read of size 8 by main thread:
#0 std::__hash_table<…RCTComponentViewClassDescriptor…>::find
#1 std::unordered_map<long long, RCTComponentViewClassDescriptor>::find
#2 -[RCTComponentViewFactory createComponentViewWithComponentHandle:] RCTComponentViewFactory.mm:210
#3 -[RCTComponentViewRegistry _dequeueComponentViewWithComponentHandle:] RCTComponentViewRegistry.mm:96
Previous write of size 8 by thread T15:
#0-#3 std::__hash_table<…RCTComponentViewClassDescriptor…>::__emplace_unique / operator[]
#4 -[RCTComponentViewFactory _registerComponentIfPossible:] RCTComponentViewFactory.mm:183
… ComponentDescriptorProviderRegistry request callback (RCTComponentViewFactory.mm:93)
With the patch below applied, the same run reports no data race.
Fix
PR #60243 takes the factory lock only around the map reads and writes. Descriptor construction and _providerRegistry.add(provider) stay outside the lock, because a lock held across them can deadlock with view managers that need main-queue setup (#53128). With the PR applied, the ThreadSanitizer run below reports no data race.
Steps to reproduce
- Build React Native from source for iOS (
ios.buildReactNativeFromSource), with ThreadSanitizer enabled onReact/Fabric/Mounting/RCTComponentViewFactory.mm(-fsanitize=threadas a per-file flag, plus the link flag). - In a bridgeless app, mount a large
<Text>batch (larger than the 1024-view recycle pool) every other frame. Right after each batch commits, while the main thread is still mounting it, create detached shadow nodes under host names the registry has never seen, from the JS thread:nativeFabricUIManager.createNode(tag, "Probe" + n, rootTag, {}, {}). Each one forces a Fallback-4 registration. - TSan reports the race above within a few seconds. Without TSan, the crash is intermittent: about 1 in 4 of our long automated UI runs, at the first mount of a legacy-interop map view.
React Native Version
0.88.1 (the factory is byte-identical in 0.88.0; same code on main at the time of writing)
Affected Platforms
Runtime - iOS
Areas
Fabric - The New Renderer
Output of npx @react-native-community/cli info
(paste yours)
Stacktrace or Logs
See the ThreadSanitizer report above. Debug: RCTAssert "ComponentView with componentHandle `…` (`Paragraph`) not found."
Reproducer
The steps above. The PR's Test Plan has the full ThreadSanitizer setup; a standalone repository can follow if maintainers want one.
Activity
react-native-bot commentedon Nov 23, 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.
adeelejaz commentedon Nov 23, 2026
Reproducer, as requested: #60246 edits
RNTesterPlayground.jsonly. Press Start; with ThreadSanitizer enabled onRCTComponentViewFactory.mm, it reports the data race within seconds. The fix is #60243; with it applied, the same run reports no race.