Repository navigation
[Hermes V1] Crash in CodeBlock::getSourceLocation when DevTools connected - missing null check on state.codeBlock #56284
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.
Description
Description
When using Hermes V1 (RCT_HERMES_V1_ENABLED=1 on iOS, hermesV1Enabled=true on Android) with React Native 0.83.4, the app crashes when React Native DevTools is connected.
The crash occurs in hermes::vm::CodeBlock::getSourceLocation() due to a null pointer dereference. The debugger's getLocationForState() does not check if state.codeBlock is null before calling ->getSourceLocation().
This is the same root cause as #55571 (which was closed due to inactivity).
Root Cause Analysis
In include/hermes/VM/Debugger/Debugger.h:
OptValue<hbc::DebugSourceLocation> getLocationForState(
const InterpreterState &state) const {
return state.codeBlock->getSourceLocation(state.offset);
// ^^^^^^^^^^^^^^^^ can be null — no null check
}And in sameStatementDifferentInstruction:
auto aLoc = getLocationForState(a);
auto bLoc = getLocationForState(b);
return a.codeBlock == b.codeBlock && aLoc->statement == bLoc->statement;
// ^^^^ aLoc/bLoc can be None when codeBlock is nullCrash Log
Thread 19 Crashed:: com.facebook.react.runtime.JavaScript
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
0 hermesvm hermes::vm::CodeBlock::getSourceLocation(unsigned int) const + 28
1 hermesvm hermes::vm::Debugger::runUntilValidPauseLocation(hermes::vm::InterpreterState&) + 144
2 hermesvm hermes::vm::Debugger::runDebugger(hermes::vm::Debugger::RunReason, hermes::vm::InterpreterState&) + 1148
3 hermesvm hermes::vm::Interpreter::interpretFunction<false, false>(...) + 3152
...
9 tracer facebook::react::TimerCallback::invoke(facebook::jsi::Runtime&) + 88
10 tracer facebook::react::TimerManager::callTimer(int)::$_0::operator()(...) + 268
ARM Thread State:
x0: 0x0000000000000000 (null — this pointer for CodeBlock)
far: 0x0000000000000000
esr: 0x92000006 (Data Abort) byte read Translation fault
Steps to Reproduce
- Use React Native 0.83.4 (or 0.84.0) with Hermes V1 enabled
- Run the app in debug mode
- Connect React Native DevTools
- The app starts logging normally, then crashes after a few seconds when high-volume JS calls (e.g. timer callbacks, TurboModule calls) trigger the debugger
Expected Behavior
DevTools should work without crashing when Hermes V1 is enabled. getLocationForState() should handle null state.codeBlock gracefully.
Suggested Fix
OptValue<hbc::DebugSourceLocation> getLocationForState(
const InterpreterState &state) const {
if (!state.codeBlock) return llvh::None;
return state.codeBlock->getSourceLocation(state.offset);
}Environment
- React Native: 0.83.4
- Hermes V1: enabled (
RCT_HERMES_V1_ENABLED=1) - Platform: iOS (also reproducible on Android)
- New Architecture: enabled
- DevTools: standalone React Native DevTools
Related Issues
- [Cross-platform] Crash in hermes::vm::CodeBlock::getSourceLocation when connecting DevTools during high-volume TurboModule calls (v0.84.0) #55571 (same crash, closed due to inactivity)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.
Activity
react-native-bot commentedon Mar 31, 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.
vchan023 commentedon Apr 23, 2026
Also seeing this on 84.1. When I run DevTools my app will suddenly crash either instantly or within the minute.
maneesh-techversant commentedon Apr 27, 2026
+1
AjayFrancisTechversant commentedon Apr 27, 2026
+1
I couldnt even debug properly using devtools because of this crash.
vchan023 commentedon May 4, 2026
Tested v0.85.2 as well and same issue. Using xcode logs for now.
Mootzali commentedon May 16, 2026
+1
I have the same issue on v0.85.3
alpha0010 commentedon May 21, 2026
DevTools can be pretty hard to use, due to these crashes.
Maybe we could get some more visibility on this issue by mirroring it to the hermes repo https://github.com/facebook/hermes/issues ? @benji-jo are you able to write that up, as you have done the analysis?
Niko-Yea commentedon May 28, 2026
+1, reproducible on React Native 0.85.3 / Expo SDK 56 / Hermes V1.
FTSTimSin commentedon Jun 4, 2026
+1
RCT_HERMES_V1_ENABLED=0.robrechtme commentedon Jun 11, 2026
Might help narrow this down: the crash is not specific to the React Native DevTools frontend. I hit the same crash (RN 0.85.3 / Expo SDK 56 / Hermes V1 / New Architecture, iOS 26.5 simulator, debug build) with no DevTools window open at all‚ the only client attached to Metro was the metro-mcp (which connects over CDP).
Nine crashes within ~35 minutes, all with the exact top frames:
The JS work underneath varied per crash (
TimerManager::callTimer,drainMicrotasks, plain function calls), so any JS activity can trigger it while a client is attached. Killing every CDP client connected to Metro stopped the crashes immediately.This rules out DevTools-frontend-specific behavior and is consistent with the root cause being entirely in the Hermes debugger as analyzed above: any client that enables the CDP
Debuggerdomain triggers it.erik-lissen commentedon Jun 12, 2026
Same repro as above - Expo 56, iOS 26.2 simulator (also on iPhone 26.5) debug build with no DevTools open. Killing all metro-mcp processes has fixed the crash
react-native-bot commentedon Jul 7, 2026
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
react-native-bot commentedon Jul 7, 2026
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
Mootzali commentedon Jul 8, 2026
Independent confirmation of @Elehiggle's fix — verified on Android + RN 0.85.3
The
getLocationForStatenull-check in this report is on the right track, but on my build it was necessary but not sufficient — with only that hunk, the crash moved rather than disappeared. The complete fix is the one @Elehiggle posted in the closely-related #55571 (#55571 (comment)... — the 2026-06-10 comment): three hunks together, with a full symbolicated stack and root-cause analysis. I'm commenting here because #56284 is the open issue and their analysis deserves a second, independent confirmation.My setup (independent from @Elehiggle's):
hermes-v0.16.0source stamp; Mavenhermes-android:250829098.0.10)React Native Bridgeless [C++ connection])Same crash site and the same second, masked symptom @Elehiggle describes: a spurious "paused in debugger" that fires on attach without any user step, because an implicit async CDP interrupt gets surfaced as
PauseReason::StepFinish. Root cause is theirs: theRetbranch inrunUntilValidPauseLocationswitches toStepMode::Outwithout ever initializingpreStepState_, so the next pause dereferencespreStepState_.codeBlock == nullptr, andsameStatementDifferentInstructionalso dereferences bothOptValuelocations withouthasValue()checks.The full fix I applied (all three hunks are @Elehiggle's, credit to them):
include/hermes/VM/Debugger/Debugger.h— this issue's null-check, plus ahasValue()guard insameStatementDifferentInstruction:lib/VM/Debugger/Debugger.cpp(runDebugger, ~line 245) — prefer a pending async-trigger reason over synthesizingStepFinish, which fixes the spurious "paused in debugger":// Done stepping. pauseReason = asyncTriggerPauseReason_ ? *asyncTriggerPauseReason_ : PauseReason::StepFinish; curStepMode_ = llvh::None; asyncTriggerPauseReason_ = llvh::None;Verification (real, on-device — not a synthetic CDP handshake): I built RN + Hermes from source with all three hunks compiled into
libhermesvm.so, installed on a physical arm64 device, attached RN DevTools, set a breakpoint in app JS, and it paused, and I stepped through, with no SIGSEGV — and no spurious "paused in debugger". Without the patch, the same sequence crashes reliably. (Method note because it burned me early: a syntheticRuntime.enable/Debugger.enablehandshake does not reliably reproduce this — only a real breakpoint that resolves a source location does.)So this is now confirmed by two independent parties on the same RN 0.85.3 / Hermes v0.16.0 setup, on both platforms (@Elehiggle on iOS + Android, me on Android). The fix is in
sdks/hermes, so it has to land infacebook/hermesand be pulled into RN on a version bump —patch-packagecan't reach it because Hermes is compiled from a downloaded source tarball at build time.Given a full root-cause + a verified fix + independent confirmation, could this be reopened / triaged? Happy to provide symbolicated stacks or test against a maintainer-preferred minimal repro.
alpha0010 commentedon Jul 14, 2026
@Mootzali Are you able to write up this issue in the hermes repo https://github.com/facebook/hermes/issues ? That might help get visibility from the correct devs. (I had started trying to submit an issue there myself, but realized I just do not have a good grasp of the internals to describe it very well.)
joeahn95 commentedon Jul 15, 2026
+1
Mootzali commentedon Jul 18, 2026
@alpha0010
Thanks for the suggestion. I'll put together an issue in the Hermes repo when I get a chance, hopefully sometime next weekend. That should give the right developers a better chance to take a look.
Sarvesh0007 commentedon Jul 18, 2026
I am facing the same issue of crash after moving to Expo SDK 57 only when the (DevTools are open)
React-native version: 0.86.0
Expo SDK version: 57.0.0
React version: 19.2.3
Mootzali commentedon Jul 18, 2026
@Sarvesh0007
Could you try the workflow I shared earlier and let me know the results?
lorenc-tomasz commentedon Aug 6, 2026
Tested facebook/hermes#2119 fix on RN 0.86.2 with Expo 57 and it seems to be working fine :)
christian-apollo commentedon Aug 6, 2026
Since this is tagged Needs: Repro — here is a repro that needs no DevTools UI, hit today on RN 0.86.2 / prebuilt
hermes-engine 250829098.0.16(iOS simulator, arm64, New Arch/Bridgeless). Root cause matches facebook/hermes#2118 (nullpreStepState_.codeBlockderef inDebugger::runUntilValidPauseLocation; thegetSourceLocationframes are inlined in the prebuilt binary).oneshot.js, then:0x0on the JS thread — sometimes tens of seconds after the last socket closed (the poisoned step state outlives the session), sometimes after the first cycle, not deterministic.Crash signature from the
.ips:react-native-bot commentedon Aug 31, 2026
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
react-native-bot commentedon Sep 7, 2026
This issue was closed because the author hasn't provided the requested feedback after 7 days.