Skip to content

V8 CHECK aborts Electron main process in GetThreadState during ExecutionInterrupted #49

Open

Description

@abbmarand

Environment

  • Electron 45.2.1 on macOS 27 arm64, main process
  • @sentry/electron 7.14.0 / @sentry/node-native 10.60.0, using eventLoopBlockIntegration
  • @sentry/node-native-stacktrace 0.5.1. The native source in 0.5.2 is identical.

What happens

When the watchdog captures a blocked main thread, the Electron main process sometimes aborts with EXC_BREAKPOINT (a failed V8 CHECK). We've seen five of these in two weeks, across several app releases. Most block captures in the same process succeed; one process had six successful captures that day before it crashed.

Crashing main thread, frame-pointer unwind (offsets symbolized against the shipped stack-trace.node):

Electron Framework   (V8 CHECK -> brk)
Electron Framework   x4
stack-trace.node     GetThreadState(v8::Isolate*, AsyncLocalStorageLookup const&) + 144
stack-trace.node     ExecutionInterrupted(v8::Isolate*, void*) + 192
Electron Framework   (JIT / V8 frames)
...
CoreFoundation       __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
AppKit               -[NSApplication run]

The fault comes after GetStackFrames has finished, inside GetThreadState.

Likely cause

@sentry/node-native registers the main thread with registerThread({ asyncLocalStorage, stateLookup: ["_currentContext", contextSymbol] }). ExecutionInterrupted then runs GetThreadState inside the RequestInterrupt callback, which:

  • reads GetContinuationPreservedEmbedderData() and calls v8::Map::Get
  • walks stateLookup with Object::Get, which can run getters and proxies
  • then JSONStringifys the result, which can call toJSON

All of this happens with no TryCatch and at whatever point V8 serviced the interrupt. Running arbitrary JS and allocating there seems unsafe. #43 reports the same serialization step freezing the thread. Here it ends in a V8 CHECK instead. Electron Framework is stripped, so we couldn't tell which CHECK fails.

Workaround

We patch @sentry/node-native to call registerThread() without the AsyncLocalStorage, so GetThreadState never runs. To keep the user and tags on block events, the poll also merges getIsolationScope().getScopeData() into the scope it passes to threadPoll. That runs on the main thread between ticks, not inside the interrupt.

Suggestion

Keep the interrupt callback to stack capture. Either collect async state outside the interrupt, or make reading it opt-in and wrap it in a TryCatch. Merging the isolation scope in poll() would cover most of what the async lookup provides today.

Activity

  1. timfish commented on Nov 17, 2026

    @timfish
    Collaborator

    We patch @sentry/node-native to call registerThread() without the AsyncLocalStorage, so GetThreadState never runs.

    This essentially removes a feature of this library. I would rather fix it than remove it if possible!

    Merging the isolation scope in poll() would cover most of what the async lookup provides today.

    It would only give you the isolation scope at the time of poll(). The isolation scope can change after that and you would get the wrong scope.

  2. abbmarand commented on Nov 18, 2026

    @abbmarand
    Author

    Oh, sorry for that haha.

    The crash is Fatal error: Invoke in DisallowJavascriptExecutionScope. V8 15.4 added a check that a RequestInterrupt callback can't run JS, and v8::Map::Get in GetThreadState runs JS. The check is off in Node's own build so it only shows up in Electron, and only when the thread is blocked inside an ALS context.

    I got it working without removing anything by using Map::AsArray() instead of Map::Get and skipping getters/proxies. Tested with the real SDK on Electron 45, the scope from the time of the block is still on the event.

    Should I open a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions