RFR: 8366787: Test runtime/StackGuardPages/TestStackGuardPagesNative.java hangs on some platforms [v2]

mazhen duke at openjdk.org
Wed Sep 10 02:52:51 UTC 2025


> #### Summary
> 
> This PR fixes a hang in the `TestStackGuardPagesNative.java` test that occurs on certain Linux distributions (e.g., CentOS 7). The fix replaces an unbounded `for(;;)` loop in the native test code (`exeinvoke.c`) with a bounded `while` loop, making the test's behavior deterministic and robust across all platforms.
> 
> #### Problem
> 
> The test would hang and eventually time out on some platforms. This was caused by an unbounded `for(;;)` loop in the `do_overflow` function, which was introduced as part of the "hardening" fix in `JDK-8295344`.
> 
> *   On platforms like **CentOS 7**, this unbounded loop would not encounter a terminating signal in a timely manner, causing the native process to hang indefinitely until killed by the test harness.
> *   In contrast, on platforms like **Ubuntu 24**, the test would coincidentally pass because a `SEGV_MAPERR` would happen to terminate the loop. This highlighted that the test's success was reliant on platform-specific side effects, masking the underlying issue.
> 
> #### Solution
> 
> The solution is to replace the unbounded `for(;;)` loop with a bounded `while` loop. The condition `while (_kp_rec_count == 0 || _rec_count < _kp_rec_count)` ensures that the loop terminates deterministically after a specific number of allocations, corresponding to the overflow depth detected in the test's first phase.
> 
> This change makes the test's logic robust and its behavior consistent across different environments.

mazhen has updated the pull request incrementally with one additional commit since the last revision:

  Restore TestStackGuardPagesNative to ProblemList as requested

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/27114/files
  - new: https://git.openjdk.org/jdk/pull/27114/files/b688eaca..18ac75c7

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=27114&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=27114&range=00-01

  Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/27114.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27114/head:pull/27114

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


More information about the hotspot-runtime-dev mailing list