8303612: runtime/StackGuardPages/TestStackGuardPagesNative.java fails with exit code 139 #25689
+4
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses an issue in
runtime/StackGuardPages/TestStackGuardPagesNative
where the native test component (exeinvoke.c
) exhibited platform-dependent behavior and did not fully align with the intended test objectives for verifying stack guard page removal on thread detachment.Summary of the Problem:
The
test_native_overflow_initial
scenario withinTestStackGuardPagesNative
showed inconsistent results:SEGV_MAPERR
to terminate a loop that should have had a defined exit condition.The core issue was that the native code's second stack overflow attempt, designed to check for guard page removal, used an unbounded loop. Its termination (and thus the test's outcome) depended on platform-specific OS behavior regarding extensive stack allocation after guard pages are supposedly modified.
Test Objective Analysis:
The primary goal of
TestStackGuardPagesNative
, particularly for the initial thread (test_native_overflow_initial
), is to:SIGSEGV
withsi_code = SEGV_ACCERR
, indicating an active stack guard page.DetachCurrentThread()
, confirm that the previously active stack guard page is no longer enforcing the same strict protection. This is ideally demonstrated by successfully allocating stack space up to the depth that previously caused theSEGV_ACCERR
, without encountering any signal.How the Original Implementation Deviated from the Test Intent:
The native
do_overflow
function, when invoked for the second phase (to check guard page removal), implemented an unconditionalfor(;;)
loop.SEGV_ACCERR
). However, the unbounded loop meant:SEGV_MAPERR
was possible, this loop ran for an excessive duration, leading to a hang.SEGV_MAPERR
. The existing result-checking logic inrun_native_overflow
incorrectly treated thisSEGV_MAPERR
as a "pass" condition for guard page removal, which is misleading. The true indication of successful guard page removal is the absence of any signal during the controlled second allocation phase.This reliance on incidental, platform-dependent signal behavior to terminate the loop (and the misinterpretation of
SEGV_MAPERR
as a success) meant the test was not robustly verifying its core objective.Proposed Solution:
This PR modifies the
do_overflow
function inexeinvoke.c
to accurately reflect the test intent for both phases of stack overflow checking, ensuring deterministic behavior:The
do_overflow
function is updated to use a singlewhile
loop whose condition correctly handles both the initial overflow check and the subsequent verification of guard page removal:Impact and Clarity of Test Outcome with This Change:
do_overflow
. The loop now has a defined boundary based on_kp_rec_count
. This directly resolves the hang observed on platforms like CentOS 7.do_overflow
: Thedo_overflow
function will now consistently:SIGSEGV
occurs andlongjmp
is called._kp_rec_count
times. If noSIGSEGV
occurs, it will complete this bounded loop and return normally. If aSIGSEGV
does occur within these_kp_rec_count
allocations,longjmp
will be called.This refinement ensures
TestStackGuardPagesNative
more accurately and reliably verifies the stack guard page lifecycle for native threads attached to the JVM.Progress
Error
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25689/head:pull/25689
$ git checkout pull/25689
Update a local copy of the PR:
$ git checkout pull/25689
$ git pull https://git.openjdk.org/jdk.git pull/25689/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25689
View PR using the GUI difftool:
$ git pr show -t 25689
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25689.diff