Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: backport V8 fix related to WASM deadlock #47610

Closed
wants to merge 2 commits into from

Conversation

targos
Copy link
Member

@targos targos commented Apr 18, 2023

The first commit is just to avoid conflicts with the second one which contains the fix.

Refs: #47297

@targos targos added dont-land-on-v14.x dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. labels Apr 18, 2023
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/v8-update

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency. labels Apr 18, 2023
@targos targos added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 18, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 18, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@targos
Copy link
Member Author

targos commented Apr 18, 2023

I'll remove the reverts because the tests are still failing.

@targos targos added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 19, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 19, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@targos targos added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 19, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 19, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

targos added 2 commits May 1, 2023 12:42
Original commit message:

    [wasm] Simplify CompileJSToWasmWrapperJob

    This CL merges some of AsyncCompileJSToWasmWrapperJob and
    CompileJSToWasmWrapperJob into a common base class. Both jobs now
    loop on a vector with an atomic index.

    Bug: chromium:1423615
    Change-Id: I7bb9cb2a57d8b659766c01e20e38d1b859d3a987
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4347597
    Reviewed-by: Clemens Backes <clemensb@chromium.org>
    Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#86675}

Refs: v8/v8@a8a11a8
Original commit message:

    [wasm] Fix deadlock in async wrapper compilation

    If compilation is cancelled while wrapper compilation is running, the
    tasks spawned for the {AsyncCompileJSToWasmWrapperJob} will return
    immediately, but {GetMaxConcurrency} will still return a positive
    value. Hence {Join()} will spawn another task, resulting in a
    livelock.

    We could fix this by checking for cancellation in {GetMaxConcurrency},
    but that requires taking the compilation state lock.
    So this CL fixes the issue by dropping the number of outstanding
    compilation units by to (basically) zero. We can't unconditionally drop
    to zero because another thread might concurrently execute a wrapper
    compilation and still call {CompleteUnit} afterwards. Hence only drop
    outstanding units by the amount of not-yet-started units.

    R=jkummerow@chromium.org

    Bug: v8:13858
    Change-Id: I5398ef370da2e7f212ca772fd1f87f659929dd6d
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4437531
    Commit-Queue: Clemens Backes <clemensb@chromium.org>
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#87143}

Refs: v8/v8@5f025d1
@targos targos added the request-ci Add this label to start a Jenkins CI on a PR. label May 1, 2023
@targos
Copy link
Member Author

targos commented May 1, 2023

rebased

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 1, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@targos
Copy link
Member Author

targos commented May 10, 2023

Landed in 0736d0b...38d261a

targos added a commit that referenced this pull request May 10, 2023
Original commit message:

    [wasm] Simplify CompileJSToWasmWrapperJob

    This CL merges some of AsyncCompileJSToWasmWrapperJob and
    CompileJSToWasmWrapperJob into a common base class. Both jobs now
    loop on a vector with an atomic index.

    Bug: chromium:1423615
    Change-Id: I7bb9cb2a57d8b659766c01e20e38d1b859d3a987
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4347597
    Reviewed-by: Clemens Backes <clemensb@chromium.org>
    Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#86675}

Refs: v8/v8@a8a11a8
PR-URL: #47610
Refs: #47297
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos added a commit that referenced this pull request May 10, 2023
Original commit message:

    [wasm] Fix deadlock in async wrapper compilation

    If compilation is cancelled while wrapper compilation is running, the
    tasks spawned for the {AsyncCompileJSToWasmWrapperJob} will return
    immediately, but {GetMaxConcurrency} will still return a positive
    value. Hence {Join()} will spawn another task, resulting in a
    livelock.

    We could fix this by checking for cancellation in {GetMaxConcurrency},
    but that requires taking the compilation state lock.
    So this CL fixes the issue by dropping the number of outstanding
    compilation units by to (basically) zero. We can't unconditionally drop
    to zero because another thread might concurrently execute a wrapper
    compilation and still call {CompleteUnit} afterwards. Hence only drop
    outstanding units by the amount of not-yet-started units.

    R=jkummerow@chromium.org

    Bug: v8:13858
    Change-Id: I5398ef370da2e7f212ca772fd1f87f659929dd6d
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4437531
    Commit-Queue: Clemens Backes <clemensb@chromium.org>
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#87143}

Refs: v8/v8@5f025d1
PR-URL: #47610
Refs: #47297
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@targos targos closed this May 10, 2023
@targos targos deleted the v8-deadlock branch May 10, 2023 12:37
targos added a commit that referenced this pull request May 12, 2023
Original commit message:

    [wasm] Simplify CompileJSToWasmWrapperJob

    This CL merges some of AsyncCompileJSToWasmWrapperJob and
    CompileJSToWasmWrapperJob into a common base class. Both jobs now
    loop on a vector with an atomic index.

    Bug: chromium:1423615
    Change-Id: I7bb9cb2a57d8b659766c01e20e38d1b859d3a987
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4347597
    Reviewed-by: Clemens Backes <clemensb@chromium.org>
    Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#86675}

Refs: v8/v8@a8a11a8
PR-URL: #47610
Refs: #47297
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos added a commit that referenced this pull request May 12, 2023
Original commit message:

    [wasm] Fix deadlock in async wrapper compilation

    If compilation is cancelled while wrapper compilation is running, the
    tasks spawned for the {AsyncCompileJSToWasmWrapperJob} will return
    immediately, but {GetMaxConcurrency} will still return a positive
    value. Hence {Join()} will spawn another task, resulting in a
    livelock.

    We could fix this by checking for cancellation in {GetMaxConcurrency},
    but that requires taking the compilation state lock.
    So this CL fixes the issue by dropping the number of outstanding
    compilation units by to (basically) zero. We can't unconditionally drop
    to zero because another thread might concurrently execute a wrapper
    compilation and still call {CompleteUnit} afterwards. Hence only drop
    outstanding units by the amount of not-yet-started units.

    R=jkummerow@chromium.org

    Bug: v8:13858
    Change-Id: I5398ef370da2e7f212ca772fd1f87f659929dd6d
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4437531
    Commit-Queue: Clemens Backes <clemensb@chromium.org>
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#87143}

Refs: v8/v8@5f025d1
PR-URL: #47610
Refs: #47297
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants