RFR: 8366328: G1: Crash on reading os::thread_cpu_time
Hamlin Li
mli at openjdk.org
Thu Sep 4 13:49:44 UTC 2025
On Thu, 4 Sep 2025 10:10:16 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>> Hi,
>>
>> Please review this patch to ensure that we do not attempt to read CPU time for GC threads that have already been terminated.
>>
>> Testing: Tier 1-3.
>
> src/hotspot/share/gc/g1/g1Policy.cpp line 672:
>
>> 670: // Only compute concurrent GC CPU time if the VM is not in the process of shutting down.
>> 671: double concurrent_gc_cpu_time_ms = 0.0;
>> 672: if (!_g1h->is_shutting_down()) {
>
> Why is `is_shutting_down` checked here? Can its caller ensure we are not in shutdown, e.g. `G1CollectedHeap::do_collection_pause_at_safepoint`?
>
> The current method name kind of suggests that we are in normal gc-pause, not shutdown process, IMO.
Is it possible for following a situation to occur?
1. thread A run to here
2. thread B call G1CollectedHeap::stop()
3. then after a while, thread A execute following 2 lines.
If it's possible, could it still cause the similar crash in some extreme situation?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27087#discussion_r2322237509
More information about the hotspot-gc-dev
mailing list