RFR: 8251570: 8215624 causes assert(worker_id <' _n_workers) failed: Invalid worker_id

Stefan Karlsson stefan.karlsson at oracle.com
Fri Aug 14 14:40:07 UTC 2020

Hi all,

Please review this patch to fix a newly introduced bug where there can 
be a mismatch between the number of parallel heap inspection threads and 
the number of used GC threads


The assert triggers because of this code:
      ParallelObjectIterator* poi = 
      if (poi != NULL) {
        ParHeapInspectTask task(poi, cit, filter);

G1's parallel_object_iterator sets up a HeapRegionClaimer with 
parallel_thread_num, while run_task uses active_workers() of the used 

The original patch also has another, latent bug. Both ZGC and Shenandoah 
uses the wrong WorkGang in run_task. Currently, non of those GCs provide 
a parallel_object_iterator, so the code isn't executed ATM.

The proposed fix for this is to simplify the code and introduce a 
concrete function CollectedHeap::run_task_at_safepoint that takes the 
number of requested workers as a parameter, and dispatches the task 
through the CollectedHeap::get_safepoint_workers() workers (if provided 
by the GC).

- Locally with the failing tests and all GCs
- tier1-tier5 on Linux


More information about the hotspot-gc-dev mailing list