Skip to content

deps: V8: backport wasm wrapper lifetime fix - #66376

Open
ThatKJ wants to merge 2 commits into
nodejs:v24.x-stagingfrom
ThatKJ:fix-v24-wasm-wrapper
Open

ThatKJ wants to merge 2 commits into
nodejs:v24.x-stagingfrom
ThatKJ:fix-v24-wasm-wrapper

Conversation

@ThatKJ

@ThatKJ ThatKJ commented Sep 28, 2026

Copy link
Copy Markdown

Backports the V8 fixes for the wasm import wrapper lifetime issue reported in #66366.

This includes:

  • V8 68210d500a — adds wrapper refcount checks
  • V8 9b8ca54d5a — fixes lookup of wrappers already marked as is_dying

The latter prevents a dying wrapper from being added to the current WasmCodeRefScope, avoiding the race that can lead to the jit_page_->allocations_.erase(addr) == 1 CHECK / crash.

Both commits applied cleanly to v24.x-staging, and the v8_embedder_string was incremented for each backport.

Local Node build completed successfully.

Refs: #66366

@ThatKJ
ThatKJ requested a review from a team as a code owner September 28, 2026 09:22
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/actions
  • @nodejs/devcontainer
  • @nodejs/tsc

@nodejs-github-bot nodejs-github-bot added meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory. labels Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@ThatKJ
ThatKJ changed the base branch from main to v24.x-staging September 28, 2026 09:24
Original commit message:

    [wasm] Add CHECKs for wrapper refcount

    We're seeing some crash reports that could be explained by
    "zombie" wrappers (freed by one code path while still in use
    by another, which then turns into UAF). To confirm or reject
    this hypothesis and shed some light on *which* code path might
    free wrappers too eagerly, this patch adds a few CHECKs.

    Bug: 407003348
    Change-Id: Ic2b527acafdd57aadd51703041c1ab65f7bf7b2c
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6415929
    Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
    Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#99572}

Refs: v8/v8@68210d5
Original commit message:

    [wasm] Fix lookup of wrappers marked "is_dying"

    We must not add a dying wrapper to the current WasmCodeRefScope.
    Doing so creates a possibility that a wrapper that's about to be
    deleted by another thread (after going through a Wasm Code GC cycle)
    will be deleted again by that WasmCodeRefScope.
    To fix this, this patch merges the "is_dying" bit and the refcount
    into a single bit field that can be updated atomically, and updates
    the WasmImportWrapperCache to use the new, more careful machinery.

    This definitely fixes issue 409379692, hopefully also 407003348.

    Bug: 407003348
    Change-Id: Ib83e9df034e8ddf3590828aea86741779ef92ab9
    Fixed: 409379692
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6450127
    Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
    Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#99765}

Refs: v8/v8@9b8ca54
@ThatKJ
ThatKJ force-pushed the fix-v24-wasm-wrapper branch from 2188a9d to 0385bee Compare September 28, 2026 09:38
@owen-harborcoat

Copy link
Copy Markdown

Tested this: the deps/v8 diff here is identical to what I built from 13987f4 in https://github.com/owen-harborcoat/wasmer-agent-sandbox/actions/runs/36353991873. With it, 0 V8 crashes in 191 repro processes; without it, 8 in 149.

@ThatKJ

ThatKJ commented Sep 28, 2026 •

Copy link
Copy Markdown
Author

@owen-harborcoat Thanks for testing this and sharing the results! Really helpful to have an independent reproduction confirming the backported V8 diff eliminates the crashes in this workload.

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

Labels

meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants