[wasm][jspi][win] Update TEB on stack switch [v8/v8 : main]

0 views
Skip to first unread message

Thibaud Michaud (Gerrit)

unread,
Apr 1, 2026, 8:48:54 AMApr 1
to Michael Lippautz, Jakob Kummerow, V8 LUCI CQ, v8-re...@googlegroups.com, was...@google.com
Attention needed from Jakob Kummerow and Michael Lippautz

Thibaud Michaud added 1 comment

Patchset-level comments
File-level comment, Patchset 8:
Thibaud Michaud . resolved

PTAL. I haven't been able to confirm that this was the root cause of the linked issue, but I suspect that this could prevent us from handling crashes gracefully on Windows. Generally speaking, I think it's a good idea to keep these limits synced with the actual stack state since we don't know exactly how Windows might use them. This would normally be done by the system's threads API or by the Fibers API, but since we are switching more "manually" we have to update these limits ourselves.

One example I found of how Windows uses these limits is to perform stack checks on large frames. For native code we usually switch the central stack so this shouldn't be an issue, but for fast C calls we stay on the secondary stacks, so that could be one case where a mismatching stack limit would cause a crash.

Open in Gerrit

Related details

Attention is currently required from:
  • Jakob Kummerow
  • Michael Lippautz
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
Gerrit-Change-Number: 7705053
Gerrit-PatchSet: 11
Gerrit-Owner: Thibaud Michaud <thib...@chromium.org>
Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
Gerrit-Reviewer: Thibaud Michaud <thib...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Comment-Date: Wed, 01 Apr 2026 12:48:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Thibaud Michaud (Gerrit)

unread,
Apr 1, 2026, 8:55:14 AMApr 1
to Michael Lippautz, Jakob Kummerow, V8 LUCI CQ, v8-re...@googlegroups.com, was...@google.com
Attention needed from Jakob Kummerow and Michael Lippautz

Thibaud Michaud added 1 comment

Patchset-level comments
Thibaud Michaud . resolved

PTAL. I haven't been able to confirm that this was the root cause of the linked issue, but I suspect that this could prevent us from handling crashes gracefully on Windows. Generally speaking, I think it's a good idea to keep these limits synced with the actual stack state since we don't know exactly how Windows might use them. This would normally be done by the system's threads API or by the Fibers API, but since we are switching more "manually" we have to update these limits ourselves.

One example I found of how Windows uses these limits is to perform stack checks on large frames. For native code we usually switch the central stack so this shouldn't be an issue, but for fast C calls we stay on the secondary stacks, so that could be one case where a mismatching stack limit would cause a crash.

Thibaud Michaud

PS: Michael for src/base/platform, Jakob for the rest. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Jakob Kummerow
  • Michael Lippautz
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
Gerrit-Change-Number: 7705053
Gerrit-PatchSet: 11
Gerrit-Owner: Thibaud Michaud <thib...@chromium.org>
Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
Gerrit-Reviewer: Thibaud Michaud <thib...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Comment-Date: Wed, 01 Apr 2026 12:55:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Thibaud Michaud <thib...@chromium.org>
unsatisfied_requirement
open
diffy

Jakob Kummerow (Gerrit)

unread,
Apr 1, 2026, 3:52:16 PMApr 1
to Thibaud Michaud, Jakob Kummerow, Michael Lippautz, V8 LUCI CQ, v8-re...@googlegroups.com, was...@google.com
Attention needed from Michael Lippautz and Thibaud Michaud

Jakob Kummerow voted and added 2 comments

Votes added by Jakob Kummerow

Code-Review+1

2 comments

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Jakob Kummerow . resolved

LGTM with a minor comment.

File src/base/platform/platform-win32.cc
Line 1910, Patchset 11 (Latest): DCHECK(thread_stack_limit == nullptr || new_limit <= thread_stack_limit);
Jakob Kummerow . unresolved

Pointer comparisons are UB unless both pointers point into the same array. Please cast to `Address` before comparing numerical pointer values.

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Lippautz
  • Thibaud Michaud
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
    Gerrit-Change-Number: 7705053
    Gerrit-PatchSet: 11
    Gerrit-Owner: Thibaud Michaud <thib...@chromium.org>
    Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
    Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
    Gerrit-Reviewer: Thibaud Michaud <thib...@chromium.org>
    Gerrit-Attention: Thibaud Michaud <thib...@chromium.org>
    Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
    Gerrit-Comment-Date: Wed, 01 Apr 2026 19:52:11 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Michael Lippautz (Gerrit)

    unread,
    Apr 2, 2026, 4:37:23 AMApr 2
    to Thibaud Michaud, Jakob Kummerow, V8 LUCI CQ, v8-re...@googlegroups.com, was...@google.com
    Attention needed from Thibaud Michaud

    Michael Lippautz voted and added 1 comment

    Votes added by Michael Lippautz

    Code-Review+1

    1 comment

    Patchset-level comments
    Michael Lippautz . resolved

    base lgtm

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Thibaud Michaud
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
    Gerrit-Change-Number: 7705053
    Gerrit-PatchSet: 11
    Gerrit-Owner: Thibaud Michaud <thib...@chromium.org>
    Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
    Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
    Gerrit-Reviewer: Thibaud Michaud <thib...@chromium.org>
    Gerrit-Attention: Thibaud Michaud <thib...@chromium.org>
    Gerrit-Comment-Date: Thu, 02 Apr 2026 08:37:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Thibaud Michaud (Gerrit)

    unread,
    Apr 2, 2026, 4:51:16 AMApr 2
    to Michael Lippautz, Jakob Kummerow, V8 LUCI CQ, v8-re...@googlegroups.com, was...@google.com

    Thibaud Michaud voted and added 1 comment

    Votes added by Thibaud Michaud

    Commit-Queue+2

    1 comment

    File src/base/platform/platform-win32.cc
    Line 1910, Patchset 11: DCHECK(thread_stack_limit == nullptr || new_limit <= thread_stack_limit);
    Jakob Kummerow . resolved

    Pointer comparisons are UB unless both pointers point into the same array. Please cast to `Address` before comparing numerical pointer values.

    Thibaud Michaud

    Done (casting to uintptr_t, Address is not declared in this scope. And casting the rhs only, the lhs has an implicit conversion operator to uintptr_t).

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
      Gerrit-Change-Number: 7705053
      Gerrit-PatchSet: 12
      Gerrit-Owner: Thibaud Michaud <thib...@chromium.org>
      Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
      Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
      Gerrit-Reviewer: Thibaud Michaud <thib...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Apr 2026 08:51:10 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Jakob Kummerow <jkum...@chromium.org>
      satisfied_requirement
      open
      diffy

      V8 LUCI CQ (Gerrit)

      unread,
      Apr 2, 2026, 5:29:36 AMApr 2
      to Thibaud Michaud, Michael Lippautz, Jakob Kummerow, v8-re...@googlegroups.com, was...@google.com

      V8 LUCI CQ submitted the change with unreviewed changes

      Unreviewed changes

      11 is the latest approved patch-set.
      The change was submitted with unreviewed changes in the following files:

      ```
      The name of the file: src/base/platform/platform-win32.cc
      Insertions: 2, Deletions: 1.

      @@ -1907,7 +1907,8 @@
      void Stack::SaveStackLimit() {
      Stack::StackSlot new_limit = ObtainCurrentThreadStackLimit();
      // The stack limit can only move down.
      - DCHECK(thread_stack_limit == nullptr || new_limit <= thread_stack_limit);
      + DCHECK(thread_stack_limit == nullptr ||
      + new_limit <= reinterpret_cast<uintptr_t>(thread_stack_limit));
      thread_stack_limit = new_limit;
      }

      ```

      Change information

      Commit message:
      [wasm][jspi][win] Update TEB on stack switch

      This is a tentative fix for issue 494341343. On Windows, the TEB
      structure describes the state of the current thread, and in particular
      it contains the bounds of the stack: StackBase and StackLimit. We don't
      currently update these values on stack switch, and running with a stack
      pointer outside of the range could lead to unexpected crashes.

      Unlike StackBase, StackLimit changes during execution: it is the limit
      of the *committed* stack space and moves down as the native stack grows.
      Its value is saved and restored in thread local field as we switch to
      and from the native stack.
      Bug: 494341343
      Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
      Reviewed-by: Jakob Kummerow <jkum...@chromium.org>
      Reviewed-by: Michael Lippautz <mlip...@chromium.org>
      Commit-Queue: Thibaud Michaud <thib...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#106241}
      Files:
      • M src/base/platform/platform-posix.cc
      • M src/base/platform/platform-win32.cc
      • M src/base/platform/platform.h
      • M src/execution/isolate.cc
      • M src/wasm/stacks.cc
      • M src/wasm/stacks.h
      • M src/wasm/turboshaft-graph-interface-inl.h
      • M src/wasm/wasm-external-refs.cc
      Change size: M
      Delta: 8 files changed, 178 insertions(+), 21 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Jakob Kummerow, +1 by Michael Lippautz
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
      Gerrit-Change-Number: 7705053
      Gerrit-PatchSet: 13
      Gerrit-Owner: Thibaud Michaud <thib...@chromium.org>
      Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
      Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
      Gerrit-Reviewer: Thibaud Michaud <thib...@chromium.org>
      open
      diffy
      satisfied_requirement

      Niklas Wenzel (Gerrit)

      unread,
      4:13 PM (3 hours ago) 4:13 PM
      to Thibaud Michaud, v8-s...@luci-project-accounts.iam.gserviceaccount.com, Michael Lippautz, Jakob Kummerow, v8-re...@googlegroups.com, was...@google.com

      Niklas Wenzel added 1 comment

      Patchset-level comments
      File-level comment, Patchset 13 (Latest):
      Niklas Wenzel . unresolved

      I believe this CL caused a regression: crbug.com/507490530

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I9547c6ad7959ed2ba60eb88d25fda15ad9966069
      Gerrit-Change-Number: 7705053
      Gerrit-PatchSet: 13
      Gerrit-Owner: Thibaud Michaud <thib...@chromium.org>
      Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
      Gerrit-Reviewer: Michael Lippautz <mlip...@chromium.org>
      Gerrit-Reviewer: Thibaud Michaud <thib...@chromium.org>
      Gerrit-CC: Niklas Wenzel <d...@nikwen.de>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 20:13:07 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages