Skip to content

NPE when parsing STICKY_CLASS tags in hprof heap dump #6357

Closed

Description

@patrickptibco

Apache NetBeans version

Apache NetBeans 18

What happened

I was attempting to load a hprof from visualvm 2.1.6 in the netbeans profiler. Instead of loading, it threw an NPE

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.netbeans.lib.profiler.heap.Instance.getInstanceId()" because the return value of "org.netbeans.lib.profiler.heap.GCRoot.getInstance()" is null
	at org.netbeans.lib.profiler.heap.HprofGCRoots.getGCRoot(HprofGCRoots.java:96)
	at org.netbeans.lib.profiler.heap.NearestGCRoot.writeConnection(NearestGCRoot.java:311)
	at org.netbeans.lib.profiler.heap.NearestGCRoot.writeClassConnection(NearestGCRoot.java:294)
	at org.netbeans.lib.profiler.heap.NearestGCRoot.computeOneLevel(NearestGCRoot.java:219)
	at org.netbeans.lib.profiler.heap.NearestGCRoot.computeGCRoots(NearestGCRoot.java:109)
	at org.netbeans.lib.profiler.heap.NearestGCRoot.getLeaves(NearestGCRoot.java:373)
	at org.netbeans.lib.profiler.heap.HprofHeap.computeRetainedSize(HprofHeap.java:704)
	at org.netbeans.lib.profiler.heap.HprofHeap.getBiggestObjectsByRetainedSize(HprofHeap.java:186)

How to reproduce

Minimal code:

package simpletest;

import java.io.File;
import org.netbeans.lib.profiler.heap.HeapFactory;

public class Test {
  public static void main(String[] args) throws Exception {
    HeapFactory.createHeap(new File(args[0])).getBiggestObjectsByRetainedSize(15); // number doesn't matter
  }
}

Minimal pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
   <dependency>
    <groupId>org.netbeans.modules</groupId>
    <artifactId>org-netbeans-lib-profiler</artifactId>
    <version>RELEASE180</version>
   </dependency>
  </dependencies>
</project>

Dump causing issues: triggering-dump.zip

I narrowed it down to the tags from computeGCRootsFor(heap.getHeapTagBound(HprofHeap.ROOT_STICKY_CLASS), rootList); being somehow wrong. Commenting out the sticky class in HprofGCRoots avoids the crash, but obviously isn't correct.

Did this work correctly in an earlier version?

No / Don't know

Operating System

RHEL8.8

JDK

openjdk 1.8.0.372 && oracle 17.0.6

Apache NetBeans packaging

Other

Anything else

From maven jars.

Triggering hprof: triggering-dump.zip

Are you willing to submit a pull request?

No

Activity

  1. added
    kind:bug
    needs:triage
    on Aug 17, 2023
  2. added
    Java
    and removed
    needs:triage
    on Aug 18, 2023
  3. removed their assignment
    on Aug 25, 2023
  4. mbien commented on Nov 19, 2023

    @mbien
    Member

    @thurka you are probably the most qualified to take a look at this since you wrote it. I suppose the heapdump format changed?

  5. 32kda commented on Jun 10, 2026

    @32kda

    I think the same issue here, while trying to get retained size:

    java.lang.NullPointerException: Cannot invoke "org.netbeans.lib.profiler.heap.Instance.getInstanceId()" because the return value of "org.netbeans.lib.profiler.heap.GCRoot.getInstance()" is null
    	at org.netbeans.lib.profiler.heap.HprofGCRoots.getGCRoot(HprofGCRoots.java:96)
    	at org.netbeans.lib.profiler.heap.NearestGCRoot.writeConnection(NearestGCRoot.java:311)
    	at org.netbeans.lib.profiler.heap.NearestGCRoot.writeConnection(NearestGCRoot.java:303)
    	at org.netbeans.lib.profiler.heap.NearestGCRoot.computeOneLevel(NearestGCRoot.java:213)
    	at org.netbeans.lib.profiler.heap.NearestGCRoot.computeGCRoots(NearestGCRoot.java:109)
    	at org.netbeans.lib.profiler.heap.NearestGCRoot.getLeaves(NearestGCRoot.java:373)
    	at org.netbeans.lib.profiler.heap.HprofHeap.computeRetainedSize(HprofHeap.java:704)
    	at org.netbeans.lib.profiler.heap.HprofHeap.getRetainedSize(HprofHeap.java:407)
    
  6. added a commit that references this issue on Jul 5, 2026
    4f123fb
  7. added 4 commits that reference this issue on Jul 19, 2026
    092044f
    54b6b01
    94b5d48
    e5f2314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Javakind:bugprofiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions