On Fri, 23 Oct 2026 14:34:55 GMT, Ashay Rane <[email protected]> wrote:
>> Ashay Rane has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Bringing back the change to `DEFAULT_STACK_SHADOW_PAGES` >> >> This makes Windows use the same number of stack shadow pages by default >> as other OSes. > > In debugging a crash that happens without this patch, I learnt of a situation > where the existing implementation can subtly corrupt memory. Sometimes this > has more visible effects like the crash, but it's possible that the execution > can silently continue with corrupted memory. Here's a reproduced paragraph > from the document explaining the circumstances: > >> Crucially, unlike the existing upstream implementation, we do not use >> `VirtualAlloc()` with `MEM_COMMIT` to commit pages, because doing so would >> forego updating `StackLimit`, leading to situations where the stack pointer >> ends up being _below_ `StackLimit`, which is an invariant failure by itself. >> As the code continues executing, the implicit calls to `__chkstk()` in VM >> code [write zeros into pages starting from >> `StackLimit`](https://devblogs.microsoft.com/oldnewthing/20260319-00/?p=112152/), >> thus overwriting used pages in the stack memory! This can lead to abrupt >> JVM crashes because return address and local variables are now corrupted. Hello @raneashay @dean-long, Thank you for this monumental effort on Windows stack handling. I wanted to share a concrete real-world production failure from the field that directly validates the necessity of this PR. In our runtime environment on **Windows x64 with JDK 27**, we hit this exact failure during an asynchronous shader compilation pipeline driven by Project Panama (FFM) downcalls and upcalls (`Shaderc` bindings via `jdk.internal.foreign`): ### The Crash Pattern - **Symptom:** Silent process termination with unhandled NTSTATUS `0xC0000005` (Access Violation), without triggering `StackOverflowError` and **without generating any `hs_err` log**. - **Context:** A newly spawned `ForkJoinWorkerThread` with only ~102 KB of stack committed out of 1024 KB reserved. - **Faulting Instruction:** C2 JIT nmethod entry for `jdk/internal/foreign/StringSupport$CharsetKind.of` (invoked via an FFM upcall stub): DowncallStub.invoke -> UpcallStub.invoke -> DirectMethodHandle$Interface.checkReceiver -> java.lang.Class.getName -> jdk.internal.foreign.StringSupport$CharsetKind.of <-- Faulting PC (C2 nmethod code entry) - **Memory Analysis:** Minidump / ProcDump analysis confirmed that the C2 nmethod's far-access stack bang (`RSP - 0x8000`) jumped into an uncommitted guard page. Because the Windows incremental stack commit mechanism was not engaged sequentially, Windows dropped it as an untracked access violation, crashing the JVM before SEH could recover it. Our application-level workaround was to isolate the FFM pipeline onto dedicated threads with a 16 MiB stack, but having this proper far-access probe recovery merged into upstream HotSpot will be a massive stability boost for real-world applications leveraging Project Panama on Windows. Looking forward to seeing this integrated! ------------- PR Comment: https://git.openjdk.org/jdk/pull/32365#issuecomment-6895910131
