RFR: 8366865: Allocation GC Pauses Triggered after JVM has started shutdown [v7]

David Holmes dholmes at openjdk.org
Fri Sep 19 05:02:20 UTC 2025


On Thu, 18 Sep 2025 22:05:59 GMT, Jonas Norlinder <duke at openjdk.org> wrote:

>> src/hotspot/share/services/cpuTimeUsage.cpp line 39:
>> 
>>> 37: 
>>> 38: static inline jlong thread_cpu_time_or_zero(Thread* thread) {
>>> 39:   assert(!thread->has_terminated(), "Cannot get cpu time for terminated thread: %zu", thread->osthread()->thread_id_for_printing());
>> 
>> Are we sure that the thread is never in a de-allocated state here? I discussed adding an assert like that in `os::thread_cpu_time` but @dholmes-ora pointed out that such asserts are in general dangerous as the they may have been dealloacted and the assert itself could result in a segmentation fault. That being said, maybe we know that all threads we could possibly poke at here in this point could be terminated but not deallocated?
>
> The assert I had in mind was to check `_is_shutting_down`

To be clear, unless you have done something to ensure a terminated thread cannot progress to deallocated, then you cannot safely query if it may be terminated.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27190#discussion_r2361769389


More information about the hotspot-dev mailing list