RFR: 8276696: ParallelObjectIterator freed at the wrong time in VM_HeapDumper

Erik Österlund eosterlund at openjdk.java.net
Mon Nov 22 14:03:34 UTC 2021


The VM_HeapDumper code uses a C heap allocated ParallelObjectIterator. It is constructed right before running a parallel operation with a work gang, but freed in the destructor of the VM_HeapDumper. This means it is created on one thread and deleted on another thread. This becomes a bit problematic when a parallel object iterator implementation uses a ThreadsListHandle (which is indeed the case for ZGC). This patch changes ParallelObjectIterator to be a StackObj, carrying a ParallelObjectIteratorImpl object, which is never exposed publicly. This ensures that construction and destruction of the internal object iterator is scoped like RAII objects, hence complying with how ThreadsListHandle is supposed to be used.

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

Commit messages:
 - 8276696: ParallelObjectIterator freed at the wrong time in VM_HeapDumper

Changes: https://git.openjdk.java.net/jdk/pull/6501/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6501&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8276696
  Stats: 70 lines in 15 files changed: 35 ins; 11 del; 24 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6501.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6501/head:pull/6501

PR: https://git.openjdk.java.net/jdk/pull/6501


More information about the serviceability-dev mailing list