JDK-8324781 : runtime/Thread/TestAlwaysPreTouchStacks.java failed with Expected a higher ratio between stack committed and reserved
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 23
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64,aarch64
  • Submitted: 2024-01-26
  • Updated: 2025-01-17
  • Resolved: 2024-12-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 23 JDK 24
21.0.5Fixed 23Fixed 24 b03Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
The following test failed in the JDK23 CI:

runtime/Thread/TestAlwaysPreTouchStacks.java

Here's a snippet from the log file:

#section:driver
----------messages:(8/324)----------
command: driver TestAlwaysPreTouchStacks
reason: User specified action: run driver TestAlwaysPreTouchStacks 
started: Fri Jan 26 19:06:32 UTC 2024
Mode: agentvm
Agent id: 20
Additional exports to unnamed modules from @modules: java.base/jdk.internal.misc
finished: Fri Jan 26 19:06:33 UTC 2024
elapsed time (seconds): 1.616
----------configuration:(15/1958)----------

<snip>

----------System.out:(5/1950)----------
Command line: [/opt/mach5/mesos/work_dir/jib-master/install/jdk-23+8-500/linux-x64-debug.jdk/jdk-23/fastdebug/bin/java -cp /opt/mach5/mesos/work_dir/slaves/0db9c48f-6638-40d0-9a4b-bd9cc7533eb8-S9726/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/e55e166a-efc3-4d3a-a206-b61e49391ab7/runs/8b72de21-746f-4cc0-92b2-19a67e94af2d/testoutput/test-support/jtreg_open_test_hotspot_jtreg_tier1_runtime/classes/1/runtime/Thread/TestAlwaysPreTouchStacks.d:/opt/mach5/mesos/work_dir/jib-master/install/jdk-23+8-500/src.full/open/test/hotspot/jtreg/runtime/Thread:/opt/mach5/mesos/work_dir/slaves/0db9c48f-6638-40d0-9a4b-bd9cc7533eb8-S9726/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/e55e166a-efc3-4d3a-a206-b61e49391ab7/runs/8b72de21-746f-4cc0-92b2-19a67e94af2d/testoutput/test-support/jtreg_open_test_hotspot_jtreg_tier1_runtime/classes/1/test/lib:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/jtreg.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/junit-platform-console-standalone-1.9.2.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/testng-7.3.0.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/jcommander-1.82.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.3.1/1/bundles/jtreg-7.3.1+1.zip/jtreg/lib/guice-5.1.0.jar -XX:+UnlockDiagnosticVMOptions -Xmx100M -XX:+AlwaysPreTouchStacks -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics TestAlwaysPreTouchStacks test ]
[2024-01-26T19:06:33.437482360Z] Gathering output for process 22690
[2024-01-26T19:06:33.594196345Z] Waiting for completion for process 22690
[2024-01-26T19:06:33.594710910Z] Waiting for completion finished for process 22690
>>>>>                             (stack: reserved=147918848, committed=2904064, peak=2904064): 147918848 - 2904064
----------System.err:(128/5337)----------
 stdout: [Alive: 2
Alive: 1
Alive: 0
Alive: 3
Alive: 5
Alive: 4
Alive: 6
Alive: 7
Alive: 8
Alive: 9
Alive: 10
Alive: 11
Alive: 12
Alive: 13
Alive: 14
Alive: 15

Native Memory Tracking:

Total: reserved=1725098922, committed=190925738
       malloc: 25385898 #28837
       mmap:   reserved=1699713024, committed=165539840

-                 Java Heap (reserved=104857600, committed=104857600)
                            (mmap: reserved=104857600, committed=104857600, at peak) 
 
-                     Class (reserved=1073842507, committed=231755)
                            (classes #721)
                            (  instance classes #608, array classes #113)
                            (malloc=100683 #1625) (peak=100827 #1623) 
                            (mmap: reserved=1073741824, committed=131072, at peak) 
                            (  Metadata:   )
                            (    reserved=67108864, committed=327680)
                            (    used=224352)
                            (    waste=103328 =31.53%)
                            (  Class space:)
                            (    reserved=1073741824, committed=131072)
                            (    used=15688)
                            (    waste=115384 =88.03%)
 
-                    Thread (reserved=148029184, committed=3014400)
                            (threads #29)
                            (stack: reserved=147918848, committed=2904064, peak=2904064)
                            (malloc=72704 #203) (peak=81232 #207) 
                            (arena=37632 #64) (peak=179336 #44)
 
-                      Code (reserved=254048944, committed=8145584)
                            (malloc=416432 #12771) (peak=416512 #12775) 
                            (mmap: reserved=253632512, committed=7729152, at peak) 
                            (arena=0 #0) (peak=984 #1)
 
-                        GC (reserved=57140362, committed=57140362)
                            (malloc=21509258 #831) (at peak) 
                            (mmap: reserved=35631104, committed=35631104, at peak) 
 
-                 GCCardSet (reserved=23432, committed=23432)
                            (malloc=23432 #303) (at peak) 
 
-                  Compiler (reserved=204104, committed=204104)
                            (malloc=3800 #32) (peak=3904 #32) 
                            (arena=200304 #4) (peak=871952 #13)
 
-                  Internal (reserved=502664, committed=502664)
                            (malloc=465800 #10531) (peak=466369 #10543) 
                            (mmap: reserved=36864, committed=36864, at peak) 
 
-                    Symbol (reserved=1163808, committed=1163808)
                            (malloc=795168 #167) (at peak) 
                            (arena=368640 #1) (at peak)
 
-    Native Memory Tracking (reserved=470832, committed=470832)
                            (malloc=9440 #91) (peak=9952 #95) 
                            (tracking overhead=461392)
 
-        Shared class space (reserved=16777216, committed=13914112, readonly=0)
                            (mmap: reserved=16777216, committed=13914112, peak=14180352) 
 
-               Arena Chunk (reserved=699040, committed=699040)
                            (malloc=699040 #96) (peak=1393880 #98) 
 
-                   Tracing (reserved=345, committed=345)
                            (malloc=345 #9) (at peak) 
 
-                Statistics (reserved=128, committed=128)
                            (malloc=128 #2) (at peak) 
 
-                 Arguments (reserved=212, committed=212)
                            (malloc=212 #5) (at peak) 
 
-                    Module (reserved=66568, committed=66568)
                            (malloc=66568 #1232) (at peak) 
 
-                 Safepoint (reserved=8192, committed=8192)
                            (mmap: reserved=8192, committed=8192, at peak) 
 
-           Synchronization (reserved=124000, committed=124000)
                            (malloc=124000 #910) (at peak) 
 
-            Serviceability (reserved=17240, committed=17240)
                            (malloc=17240 #10) (peak=17576 #14) 
 
-                 Metaspace (reserved=67121424, committed=340240)
                            (malloc=12560 #9) (at peak) 
                            (mmap: reserved=67108864, committed=327680, at peak) 
 
-      String Deduplication (reserved=704, committed=704)
                            (malloc=704 #8) (at peak) 
 
-           Object Monitors (reserved=416, committed=416)
                            (malloc=416 #2) (at peak) 
 
-                   Unknown (reserved=0, committed=0)
                            (mmap: reserved=0, committed=0, peak=20480) 
 
];
 stderr: []
 exitValue = 0

java.lang.RuntimeException: Expected a higher ratio between stack committed and reserved.
	at TestAlwaysPreTouchStacks.main(TestAlwaysPreTouchStacks.java:135)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
	at java.base/java.lang.Thread.run(Thread.java:1575)

JavaTest Message: Test threw exception: java.lang.RuntimeException
JavaTest Message: shutting down test

result: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Expected a higher ratio between stack committed and reserved.
Comments
Filed: JDK-8346476: Thread/TestAlwaysPreTouchStacks fails when run with specific JVM options
18-12-2024

[~mseledtsov] you cannot re-open a bug that has already been Fixed. If the failure is still happening then a new bug needs to be filed for it.
16-12-2024

Build: jdk-24+27 Platforms: linux-x64, linux-aarch64 CLI Options: -XX:+UnlockDiagnosticVMOptions -Xmx100M -XX:+AlwaysPreTouchStacks -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics Test: runtime/Thread/TestAlwaysPreTouchStacks.java Failure: Expected a higher amount of committed with pretouch stacksPreTouch amount: 142077952NoPreTouch amount: 225972224 ----------- More details: java.lang.RuntimeException: Expected a higher amount of committed with pretouch stacksPreTouch amount: 142077952NoPreTouch amount: 225972224 at TestAlwaysPreTouchStacks.main(TestAlwaysPreTouchStacks.java:173) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333) at java.base/java.lang.Thread.run(Thread.java:1447)
13-12-2024

I ran the test using jdk-24+27, it fails again in a similar manner. Reopening.
13-12-2024

[jdk21u-fix-request] Approval Request from Liming Liu
10-07-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/825 Date: 2024-07-05 08:55:58 +0000
09-07-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/19877 Date: 2024-06-25 07:51:35 +0000
25-06-2024

Changeset: 31e8deba Author: Liming Liu <limingliu@os.amperecomputing.com> Committer: Thomas Stuefe <stuefe@openjdk.org> Date: 2024-06-17 06:16:26 +0000 URL: https://git.openjdk.org/jdk/commit/31e8debae63e008da79e403bcb870a7be631af2c
17-06-2024

[~ qpzhang] Well, sure. But testing pretouching is not the job of this test, and if we just rely on it for that its too brittle (e.g. relies on NMTs ability to sense thread stack dimensions correctly). The funny thing is that we have tests that explicitly test pretouching, but they don't really test it. I opened https://bugs.openjdk.org/browse/JDK-8333769 to fix that.
07-06-2024

Adding `-XX:-UseMadvPopulateWrite` onto the two test cases would hide the problem in a manner, I suggest we'd better not do so. The two test cases can run on all distros not only Oracle Linux, It is good that Oracle promised a kernel fix for their bug, while the test cases are still valuable here to warn any similar issue (backport or reuse of the madv opcode) on other distros with default JDK flags.
06-06-2024

Please just run the test with -XX:-UseMadvPopulateWrite. That should solve the problem for the test. The test's purpose is not to test Oracle Linux' inability to handle madvise flags correctly but to test -XX:+AlwaysPreTouchStacks. We can and should deal with the Oracle Linux problem independently (Note that I reported the problem to Oracle secalert back in March, and they promised a kernel fix).
22-05-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18592 Date: 2024-04-03 08:12:22 +0000
03-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18417 Date: 2024-03-21 02:49:48 +0000
21-03-2024

https://bugs.openjdk.org/browse/JDK-8324776?focusedId=14651275&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14651275 explained why this happened on UEK 5.4.17 instead Linux 5.4 mainline.
21-02-2024

We will investigate this issue as a matter of urgency.
29-01-2024

This test was ProblemListed on linux-all via: JDK-8324785 ProblemList two tests on linux due to JDK-8315923
26-01-2024

[~qpzhang] - It looks like an existing test is failing in Tier3 and intermittently in Tier1 in the Oracle CI system (Mach5).
26-01-2024

This failure first occurred in jdk-23+8-499-tier3 and the only changeset in that build-ID is this one: JDK-8315923 pretouch_memory by atomic-add-0 fragments huge pages unexpectedly
26-01-2024