Repository navigation
fix(apple/v8): stop the runtime aborting on teardown - #118
Merged
Merged
Conversation
Every V8 'nsr run' aborted at exit with 'Cannot exit non-entered context', so the Performance (v8) job failed on every PR into refactor. ~Runtime kept NapiScope open around js_free_napi_env. NapiScope enters env->context(), a Local that aliases the env's own persistent slot, and freeing the env destroys that slot; the scope's Context::Exit then read a dead handle. The env is now freed in its own scope that enters a HandleScope-owned copy of the context, after globalScope_ is closed. That exposed a second crash: the ES module cache keeps thread-local Globals per isolate and nothing released them, so they were reset at exit against the disposed isolate. js_free_runtime now calls the existing CleanupESModuleSystem before disposing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every V8
nsr runon macOS aborts at exit with:It happens even for an empty script, after the script has finished. The Performance (v8) CI job runs the CLI, so it has failed on every PR into
refactor, including #68 and #69.Cause
~Runtimekeeps aNapiScopeopen aroundjs_free_napi_env.NapiScopeentersenv->context(), which is aLocalpointing straight into the env's own persistent slot. The header warns against resetting that slot while theLocalis in use. Freeing the env destroys the slot, so when the scope closes,Context::Exitreads a dead handle and V8 aborts.Global<Module>s per isolate in a thread-local map, and nothing released them.CleanupESModuleSystemexists but was never called, so the map was cleared at process exit, after the isolate was already disposed, and crashed.Fix
globalScope_is closed. That scope enters a copy of the context owned by its ownHandleScope, so the env's finalizers still run inside the context. Non-V8 engines are unchanged.js_free_runtimecallsCleanupESModuleSystembefore disposing the isolate.Testing
This PR's own Performance (v8) check will still fail: it builds its baseline from
refactor, which still has the bug. Once this is merged, the baseline is fixed for every later PR, including #117.🤖 Generated with Claude Code