fix: dangling CFunction pointer in node:wasi fast API calls#51867
Merged
Conversation
Since the V8 change to store the v8::CFunction pointer directly in FunctionTemplateInfo (backported for node startup snapshot support), the CFunction passed to FunctionTemplate::New must outlive the template. WasiFunction::SetFunction kept it in a stack local, leaving a dangling pointer that TurboFan dereferences when compiling the fast API call, crashing all wasi tests under --turbo-fast-api-calls. Make the per-instantiation CFunction static, mirroring the wasi half of nodejs/node#62572; the matching external reference registration fix already shipped in the snapshot patch.
deepak1556
approved these changes
Jun 3, 2026
|
Release Notes Persisted
|
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.
Fixes the
wasi/test-wasi-*SIGSEGVs on 42-x-y reported in #51859 (comment) (deepak1556) after #51831.fastapi_store_v8_cfunction_pointer_directly_in.patch) makesFunctionTemplate::Newstore thev8::CFunctionpointer instead of copying it;WasiFunction::SetFunctionkept theCFunctionin a stack local, so TurboFan dereferenced a dangling pointer when compiling the fast API call → SIGSEGV in every wasi test under--turbo-fast-api-calls.electron_enable_node_startup_snapshot_generation_in_chromium_s_v8.patch, which already carries the matchingnode_external_reference.hhalf: make the per-instantiationCFunctionstatic.wasi/test-wasi-cant_dotdotSIGSEGVs before, full wasi suite passes 26/26 after.Notes: Fixed a crash when calling
node:wasifunctions with fast API calls enabled.