On Tue, 24 Nov 2026 22:30:32 GMT, David Holmes <[email protected]> wrote:
>> Ashay Rane has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Extend the test to run on Linux, macOS, and on Windows
>>
>> - To maintain compatibility with `handle_stack_overflow()` in
>> os_posix.cpp, the handler for `EXCEPTION_STACK_OVERFLOW` does not
>> check for `_thread_in_vm` or `_thread_in_native`. All non-Java
>> executions continue execution.
>>
>> - TestWindowsStackOverflow (renamed to TestStackOverflowExceptions) is
>> now a cross-platform test (it runs on Linux, Windows, and macOS).
>>
>> - That test checks the following scenarios:
>>
>> - Unrecoverable overflow handling (after touching a red zone page)
>>
>> - Recoverable overflow handling from _Java_ threads (interpreter, C1,
>> and C2)
>>
>> - Recoverable overflow handling from _native_ threads (interpreter,
>> C1, and C2)
>>
>> - Back-to-back recoverable overflow handling (to exercise both code
>> paths on Windows)
>>
>> - Since this patch no longer restricts `StackLimit` growth to just
>> Java-thread execution (since a native thread, too, could potentially
>> bang past `StackLimit`), I've updated TestWindowsStackLimit to
>> exercise both Java- and native-thread execution.
>
> src/hotspot/os/windows/os_windows.cpp line 2715:
>
>> 2713: static void report_fatal_stack_overflow(JavaThread* thread,
>> 2714: struct _EXCEPTION_POINTERS* exceptionInfo, address pc,
>> 2715: const char* message, bool disable_red_zone) {
>
> Suggestion:
>
> static void report_fatal_stack_overflow(JavaThread* thread,
> struct _EXCEPTION_POINTERS*
> exceptionInfo, address pc,
> const char* message, bool
> disable_red_zone) {
Fixed in the most recent commit (and I'll pay closer attention to the
formatting the next time).
> src/hotspot/os/windows/os_windows.cpp line 2727:
>
>> 2725:
>> 2726: static LONG handle_stack_overflow_in_yellow_zone(JavaThread* thread,
>> 2727: struct _EXCEPTION_POINTERS* exceptionInfo, address pc) {
>
> Suggestion:
>
> static LONG handle_stack_overflow_in_yellow_zone(JavaThread* thread,
> struct _EXCEPTION_POINTERS*
> exceptionInfo, address pc) {
Fixed in the most recent commit.
> src/hotspot/os/windows/os_windows.cpp line 2758:
>
>> 2756: }
>> 2757:
>> 2758: // The thread is in an unexpected state, so terminate out of
>> abundant caution.
>
> I think `_thread_blocked` can be handled the same as `_thread_in_vm`. Though
> per the original code I think all we need to distinguish is `in java` or not.
The code now uses a catch-all case for non-Java execution. Thanks for pointing
that out!
> src/hotspot/os/windows/os_windows.cpp line 2814:
>
>> 2812: if (exception_code == EXCEPTION_STACK_OVERFLOW) {
>> 2813: // After reporting a stack overflow exception, Windows makes the
>> terminal
>> 2814: // growth guard page, the stack guaratee pages, and the bottom
>> page both
>
> Suggestion:
>
> // growth guard page, the stack guarantee pages, and the bottom page
> both
Fixed in the most recent commit.
> test/hotspot/jtreg/runtime/StackGuardPages/TestWindowsStackOverflow.java line
> 28:
>
>> 26: * @bug 8339569
>> 27: * @summary Verifies both recoverable and unrecoverable Windows stack
>> overflow handling
>> 28: * @requires os.family == "windows" & (os.arch == "amd64" | os.arch ==
>> "aarch64")
>
> Do we need the arch check? What else is there?
Makes sense. I had first started with just AArch64, but either way, you're
right that we don't need the arch check if we're testing on both x64 and ARM64.
> test/hotspot/jtreg/runtime/StackGuardPages/TestWindowsStackOverflow.java line
> 29:
>
>> 27: * @summary Verifies both recoverable and unrecoverable Windows stack
>> overflow handling
>> 28: * @requires os.family == "windows" & (os.arch == "amd64" | os.arch ==
>> "aarch64")
>> 29: * @requires !jdk.static
>
> What is the issue with the static build? Perhaps add a `@comment` to explain.
Sorry, this was a result of copying annotations from a different test file. I
ran the static images build and ran the test using jtreg, and since it didn't
complain, I've removed the non-static requirement.
> test/hotspot/jtreg/runtime/StackGuardPages/TestWindowsStackOverflow.java line
> 33:
>
>> 31: * @run main/native ${test.main.class} fatal
>> 32: * @run main/othervm -Xcomp -XX:TieredStopAtLevel=1 ${test.main.class}
>> recoverable
>> 33: * @run main/othervm -Xcomp -XX:-TieredCompilation ${test.main.class}
>> recoverable
>
> If you are using -Xcomp explicitly then it would be better to split out into
> a separate @test block that is flagless, else this at best will waste
> resource in higher tiers and at worst won't work correctly with some flag
> combinations.
Makes sense, thanks! Fixed in the most recent commit.
> test/hotspot/jtreg/runtime/StackGuardPages/TestWindowsStackOverflow.java line
> 73:
>
>> 71: // HotSpot should have terminated with an unrecoverable overflow.
>> 72: String msg = "Unexpected return from native red-zone bang,
>> expected termination";
>> 73: throw new AssertionError(msg);
>
> Just use `RuntimeException` as this really isn't an assertion.
Fixed in the most recent commit.
> test/hotspot/jtreg/runtime/StackGuardPages/TestWindowsStackOverflow.java line
> 89:
>
>> 87: caughtCount += 1;
>> 88: }
>> 89: }
>
> How does this test both kinds? Once we get the first SOE each loop iteration
> should act exactly the same. Or does the first SOE cause something to change
> for the subsequent ones?
It's true that after the first StackOverflowError exception, every loop
iteration behaves the same. I've reduced this to just twice instead of
`EXPECTED_OVERFLOW_COUNT` (which was 5). For non-Windows tests, the second
instance is unnecessary, but hopefully the comments clarify that.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702378599
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702380259
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702385400
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702386309
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702393681
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702400958
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702402985
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702403717
PR Review Comment: https://git.openjdk.org/jdk/pull/34043#discussion_r4702422441