On Wed, 4 Nov 2026 17:33:21 GMT, Ashay Rane <[email protected]> wrote:

> Without this patch, HotSpot uses `VirtualAlloc()` with `MEM_COMMIT` to
> make Windows convert stack pages from "reserved" to "committed", but
> doing so does not update the `StackLimit` field in the Thread
> Environment Block (TEB) tracked by Windows.  Subsequent use of the stack
> by HotSpot can cause the stack pointer to be _below_ `StackLimit`, which
> breaks the invariant expected by the Win32 API functions like
> `__chkstk()`.
> 
> To fix this problem, this patch touches pages one by one, starting from
> `StackLimit` down to the target address.  This has the intended effect
> of commiting the pages, but it also correctly updates `StackLimit`.
> 
> The included test reliably fails without this patch, and it passes with
> this patch.  I validated this patch using Tier 1 through 3 tests in the
> JDK, HotSpot, and LangTools test groups.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: eb4e83bd
Author:    Ashay Rane <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/eb4e83bddc6961d165b3eeca5fa1d2cf6bfcf622
Stats:     134 lines in 4 files changed: 127 ins; 2 del; 5 mod

8394484: C2 stack bang on Windows can lead to non-recoverable crash

Reviewed-by: kvn, dlong, macarte

-------------

PR: https://git.openjdk.org/jdk/pull/33729

Reply via email to