JDK-8361238 : G1 tries to get CPU info from terminated threads at shutdown
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 26
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-07-02
  • Updated: 2025-07-03
  • Resolved: 2025-07-03
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 26
26 b05Fixed
Related Reports
Causes :  
Relates :  
Description
After JDK-8274051 some test show asserts on AIX and crashes on Linux with musl.

It happens during shutdown of the VM and seems to be caused by collecting CPU usage information from already terminated threads. The tests run with -Xlog:gc+remset+exit=trace
An example test is gc/g1/TestRemsetLogging.java.

On Linux with musl it seems that pthread_getcpuclockid gets a SIGSECV when called with a terminated thread-id.
  [ld-musl-x86_64.so.1+0x66b18]  pthread_getcpuclockid+0x0
V  [libjvm.so+0xf134b6]  G1RemSetSummary::update()::CollectData::do_thread(Thread*)+0x16  (g1RemSetSummary.cpp:47)
V  [libjvm.so+0xe605a5]  G1ConcurrentRefineThreadControl::worker_threads_do(ThreadClosure*)+0x55  (g1ConcurrentRefine.cpp:125)
V  [libjvm.so+0xf144b9]  G1RemSetSummary::G1RemSetSummary(bool)+0x89  (g1RemSetSummary.cpp:53)
V  [libjvm.so+0xef6193]  G1RemSet::print_summary_info()+0x73  (g1RemSet.cpp:1688)
V  [libjvm.so+0xe16b98]  G1CollectedHeap::print_tracing_info() const+0x18  (g1CollectedHeap.cpp:2174)
V  [libjvm.so+0x107dfb0]  before_exit(JavaThread*, bool)+0x420  (java.cpp:516)
V  [libjvm.so+0x1cdec17]  Threads::destroy_vm()+0x1a7  (threads.cpp:974)
V  [libjvm.so+0x11cab0c]  jni_DestroyJavaVM+0xac  (jni.cpp:3741)
C  [libjli.so+0x3fee]  JavaMain+0x3ee  (java.c:668)
C  [libjli.so+0x7a49]  ThreadJavaMain+0x9  (java_md.c:646)

On AIX there is an assert in os::thread_cpu_time that asserts  that the CPU time is non negative, but it gets -1 as return code for an already terminated thread from os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time)

0x000000011023bdf0 - 0x0900000020ce5904 libjvm.so::os::Aix::platform_print_native_stack(outputStream*, void const*, char*, int, unsigned char*&)+0x24  (C++ uses_alloca saves_lr stores_bc gpr_saved:1 fixedparms:5 parmsonstk:1)
0x000000011023be70 - 0x0900000020ce57b8 libjvm.so::NativeStackPrinter::print_stack(outputStream*, char*, int, unsigned char*&, bool, int)+0x58  (C++ fp_present uses_alloca saves_cr saves_lr stores_bc gpr_saved:6 fixedparms:7 parmsonstk:1)
0x000000011023bf80 - 0x090000002147ceb4 libjvm.so::VMError::report(outputStream*, bool)+0x1cf4  (C++ fp_present uses_alloca saves_cr saves_lr stores_bc gpr_saved:18 fixedparms:2 parmsonstk:1)
0x000000011023ca70 - 0x0900000020a57030 libjvm.so::VMError::report_and_die(int, char const*, char const*, char*, Thread*, unsigned char*, void const*, void const*, char const*, int, unsigned long)+0x870  (C++ uses_alloca saves_lr stores_bc gpr_saved:18 fixedparms:8 parmsonstk:1)
0x000000011023cc50 - 0x0900000020a564e0 libjvm.so::report_vm_error(char const*, int, char const*, char const*, ...)+0xa0  (C++ uses_alloca saves_lr stores_bc gpr_saved:5 fixedparms:4 parmsonstk:1)
0x000000011023cd10 - 0x0900000020a76a68 libjvm.so::os::thread_cpu_time(Thread*)+0x68  (C++ uses_alloca saves_lr stores_bc gpr_saved:1 fixedparms:1 parmsonstk:1)
0x000000011023cd90 - 0x0900000020f1f8d8 libjvm.so::G1ConcurrentRefineThread::cpu_time()+0x18  (C++ uses_alloca saves_lr stores_bc gpr_saved:1 fixedparms:1 parmsonstk:1)
0x000000011023ce10 - 0x0900000020f1f7b4 libjvm.so::G1RemSetSummary::update()::CollectData::do_thread(Thread*)+0x34  (C++ uses_alloca saves_lr stores_bc gpr_saved:4 fixedparms:2 parmsonstk:1)
0x000000011023cea0 - 0x0900000020f1fa68 libjvm.so::G1ConcurrentRefineThreadControl::worker_threads_do(ThreadClosure*)+0xa8  (C++ uses_alloca saves_lr stores_bc gpr_saved:7 fixedparms:2 parmsonstk:1)
0x000000011023cf50 - 0x0900000020f1f95c libjvm.so::G1ConcurrentRefine::threads_do(ThreadClosure*)+0x1c  (C++ uses_alloca saves_lr stores_bc gpr_saved:1 fixedparms:2 parmsonstk:1)
0x000000011023cfd0 - 0x0900000020f1f6cc libjvm.so::G1RemSetSummary::G1RemSetSummary(bool)+0xec  (C++ uses_alloca saves_lr stores_bc gpr_saved:4 fixedparms:2 parmsonstk:1)
0x000000011023d080 - 0x0900000021207db8 libjvm.so::G1RemSet::print_summary_info()+0x78  (C++ uses_alloca saves_lr stores_bc gpr_saved:6 fixedparms:1 parmsonstk:1)
0x000000011023d1e0 - 0x0900000021207cc4 libjvm.so::G1CollectedHeap::print_tracing_info() const+0x24  (C++ uses_alloca saves_lr stores_bc gpr_saved:2 fixedparms:1 parmsonstk:1)
0x000000011023d260 - 0x0900000020c55550 libjvm.so::before_exit(JavaThread*, bool)+0x450  (C++ fp_present uses_alloca saves_cr saves_lr stores_bc gpr_saved:11 fixedparms:2 parmsonstk:1)
0x000000011023d4b0 - 0x0900000020cb8774 libjvm.so::Threads::destroy_vm()+0x254  (C++ fp_present uses_alloca saves_cr saves_lr stores_bc gpr_saved:6 parmsonstk:1)
0x000000011023d590 - 0x0900000020cb8474 libjvm.so::jni_DestroyJavaVM+0x114  (C++ uses_alloca saves_lr stores_bc gpr_saved:4 fixedparms:1 parmsonstk:1)
0x000000011023d640 - 0x000000010001114c java::JavaMain+0x68c      (C++ saves_lr stores_bc gpr_saved:11 fixedparms:1 parmsonstk:1)
0x000000011023d730 - 0x0000000100010a70 java::ThreadJavaMain+0x10  (C++ saves_lr stores_bc fixedparms:1 parmsonstk:1)
0x000000011023d7a0 - 0x090000000056204c libpthreads.a::_pthread_body+0xec  (C saves_lr stores_bc gpr_saved:1 fixedparms:1 )
0x000000011023d820 - 0x0000000000000000 


Comments
Hi [~tschatzl] should we maybe add at least more asserts for os::thread_cpu_time returning -1 ? Seems we call this method e.g. in G1 coding : https://github.com/search?q=repo%3Aopenjdk%2Fjdk%20%22os%3A%3Athread_cpu_time%22&type=code but do not really check for failures of the method (but those can occur, we saw it in this example).
03-07-2025

Changeset: 6c9236c8 Branch: master Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2025-07-03 06:59:00 +0000 URL: https://git.openjdk.org/jdk/commit/6c9236c80c236487a7c37dcb947c0f9192322208
03-07-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26086 Date: 2025-07-02 07:57:28 +0000
02-07-2025