Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337421

Summary: NullPointerException during parsing of heap dump
Product: [Tools] MAT Reporter: Lubor Vágenknecht <lubor.vagenknecht>
Component: CoreAssignee: Project Inbox <mat.core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: andrew_johnson, krum.tsvetkov, sourabh2k6, tmccord11, wjgerritsen, wxie
Version: 1.0   
Target Milestone: 1.6.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Dump that generates a NullPointerException while parsing none

Description Lubor Vágenknecht CLA 2011-02-17 07:18:32 EST
An internal error occurred during parsing of heap dump:

java.lang.NullPointerException
	at org.eclipse.mat.hprof.HprofParserHandlerImpl.beforePass2(HprofParserHandlerImpl.java:123)
	at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:72)
	at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:203)
	at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:114)
	at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:143)
	at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:123)
	at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:56)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Use the attached heap dump to find an error.

eclipse.buildId=unknown
java.version=1.6.0_21
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=cs_CZ
Command-line arguments:  -os win32 -ws win32 -arch x86

Eclipse Memory Analyzer Version 1.0.1
Comment 1 Andrew Johnson CLA 2011-02-17 07:30:11 EST
It looks like no class called java.lang.Class has been found in the dump. Is the dump corrupted?
Comment 2 Andrew Johnson CLA 2011-03-03 04:30:00 EST
Does the jhat tool supplied with Oracle/Sun SDKs read the dump successfully?

Was the heap dump transferred using ftp? Is it possible it was transferred in ASCII not binary?
Comment 3 Krum Tsvetkov CLA 2011-05-23 05:32:33 EDT
I reduced the severity of this bug. We haven't heard anything new and haven't been able to reproduce.
Comment 4 wxie CLA 2011-07-12 11:56:17 EDT
I got the exact same error. hprof is in binary format correct, and I opened the hprof file with jhat with the following message:

C:\Program Files\Java\jdk1.6.0_06\bin>jhat z:\temp\java_pid7036.hprof
Reading from z:\temp\java_pid7036.hprof...
Dump file created Fri Jul 08 12:06:53 EDT 2011
Snapshot read, resolving...
Resolving 0 objects...
WARNING:  hprof file does not include java.lang.Class!
WARNING:  hprof file does not include java.lang.String!
WARNING:  hprof file does not include java.lang.ClassLoader!
Chasing references, expect 0 dots
Eliminating duplicate references
Snapshot resolved.
Started HTTP server on port 7000

When I click the "Show finalizer summary" link in jhat, I got the following error. thanks.

Exception in thread "Thread-53" java.lang.NullPointerException
        at com.sun.tools.hat.internal.model.Snapshot.getFinalizerObjects(Snapshot.java:393)
        at com.sun.tools.hat.internal.server.FinalizerSummaryQuery.run(FinalizerSummaryQuery.java:26)
        at com.sun.tools.hat.internal.server.HttpReader.run(HttpReader.java:181)
        at java.lang.Thread.run(Thread.java:619)
Comment 5 tmccord CLA 2011-09-20 12:18:14 EDT
I have observed this with heap dumps taken from JDK 1.5.0_11+ JDKs on Red Hat.  Jmap was used to generate the heap dump.  However, histogram listing from jmap does show java.lang.Class: 
 
Size    Count   Class description
-------------------------------------------------------
117016288       1112362 char[]
54692528        502140  java.lang.Object[]
52775520        365553  * ConstMethodKlass
...
9778688 152792  java.util.HashMap
9408320 58802   org.apache.jetspeed.om.folder.proxy.FolderProxy
8638920 56835   java.lang.reflect.Method
8135808 84748   org.apache.jetspeed.om.page.proxy.PageProxy
6608736 11798   * MethodDataKlass
5615280 31905   java.lang.Class
Comment 6 Andrew Johnson CLA 2012-02-21 13:06:12 EST
Failure is at:
        ClassImpl javaLangClass = javaLangClasses.get(0);
Perhaps we could need to create dummy classes for java.lang.Class and java.lang.Classloader if they do not exist due to a corrupt dump.
The DTFJ parser does something similar.
Comment 7 WJ Gerritsen CLA 2016-02-02 06:53:11 EST
Created attachment 259486 [details]
Dump that generates a NullPointerException while parsing

I do have this same issue while reading the attached dump. The error log contains:

!SESSION 2016-02-02 12:47:15.943 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_66
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64

!ENTRY org.eclipse.mat.ui 1 0 2016-02-02 12:47:53.775
!MESSAGE Detected compressed references, because with uncompressed 64-bit references the array at 0xfab008c8 would overlap the array at 0xfab00378

!ENTRY org.eclipse.mat.ui 1 0 2016-02-02 12:47:53.969
!MESSAGE Heap C:\temp\mon.bin contains 123,987 objects

!ENTRY org.eclipse.core.jobs 4 2 2016-02-02 12:47:54.063
!MESSAGE An internal error occurred during: "Parsing heap dump from 'C:\temp\mon.bin'".
!STACK 0
java.lang.NullPointerException
	at org.eclipse.mat.hprof.HprofParserHandlerImpl.resolveClassHierarchy(HprofParserHandlerImpl.java:587)
	at org.eclipse.mat.hprof.Pass2Parser.readInstanceDump(Pass2Parser.java:205)
	at org.eclipse.mat.hprof.Pass2Parser.readDumpSegments(Pass2Parser.java:159)
	at org.eclipse.mat.hprof.Pass2Parser.read(Pass2Parser.java:89)
	at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:94)
	at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:222)
	at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:126)
	at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:145)
	at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:83)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

And indeed with jhat I can navigate the heap dump
Comment 8 Sourabh Kumar CLA 2016-07-14 02:26:10 EDT
I am also facing the same issue. Can you please let me know how to add the patch provided in eclipse.
Comment 9 Sourabh Kumar CLA 2016-07-14 02:27:07 EDT
I am also facing the same issue. Can you please let me know how to add the patch provided in eclipse.
Comment 10 Andrew Johnson CLA 2016-11-24 08:03:40 EST
The fix for bug 471757 allows me to open the dump attached to this bug.

*** This bug has been marked as a duplicate of bug 471757 ***