RFR: 8366328: G1: Crash on reading os::thread_cpu_time

Ivan Walulya iwalulya at openjdk.org
Thu Sep 4 14:27:42 UTC 2025


On Thu, 4 Sep 2025 13:47:29 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> 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?

The assumption is that thread B is at a safepoint if thread A is executing `record_pause_start_time()`.  So this interleaving is not possible. iiuc

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27087#discussion_r2322382826


More information about the hotspot-gc-dev mailing list