JDK-8321565 : [REDO] Heap dump does not contain virtual Thread stack references
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 19,21
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2023-12-08
  • Updated: 2024-03-08
  • Resolved: 2023-12-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22 JDK 23
22Fixed 23 b02Fixed
Related Reports
Cloners :  
Relates :  
Relates :  
Sub Tasks
JDK-8321560 :  
Description
ADDITIONAL SYSTEM INFORMATION :
Ubunu 22.10 x86_64
openjdk version "21-ea" 2023-09-19
OpenJDK Runtime Environment (build 21-ea+3-124)
OpenJDK 64-Bit Server VM (build 21-ea+3-124, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
HPROF files do not contain stack references of unmounted VirtualThreads. This would be necessary for all analyses based on reachability like biggest objects and dominator trees.
The HPROF file format generally supports variable-length HPROF_GC_INSTANCE_DUMP records so the references could be appended to the StackChunk dump.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
With the attached source, create a HPROF file and open it in a HPROF analyser that can show incoming references.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
There should be a reference to the VThreadReferenced instance.
ACTUAL -
There are no references to the VThreadReferenced instance.

---------- BEGIN SOURCE ----------
-- HprofVThreadStackRef.java ---------------------------------------------------------
import com.sun.management.HotSpotDiagnosticMXBean;

import java.io.File;
import java.lang.management.ManagementFactory;
import java.util.concurrent.CountDownLatch;

public class HprofVThreadStackRef {
    public static void main(String[] args) throws Exception {
        CountDownLatch dumpedLatch = new CountDownLatch(1);
        Thread vthread = Thread.ofVirtual().start(() -> {
            Object referenced = new VThreadReferenced();
            System.out.println(referenced.getClass());
            await(dumpedLatch);
            System.out.println(referenced.getClass());
        });
        Thread.sleep(2000); // wait for reference and unmount
        HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
        File hprofFile = new File("vthread_test.hprof");
        hprofFile.delete();
        hotSpotDiagnosticMXBean.dumpHeap(hprofFile.getPath(), true);
        dumpedLatch.countDown();
        vthread.join();
    }

    private static void await(CountDownLatch dumpedLatch) {
        try {
            dumpedLatch.await();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    public static class VThreadReferenced {
    }
}
--------------------------------------------------------------------------------------

---------- END SOURCE ----------

FREQUENCY : always



Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk22/pull/21 Date: 2023-12-19 22:48:28 +0000
19-12-2023

Changeset: cf948548 Author: Alex Menkov <amenkov@openjdk.org> Date: 2023-12-13 18:47:04 +0000 URL: https://git.openjdk.org/jdk/commit/cf948548c390c42ca63525d41a9d63ff31349c3a
13-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17040 Date: 2023-12-08 22:29:12 +0000
08-12-2023