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

Bug 320366

Summary: Top Components report fails due to unknown object
Product: [Tools] MAT Reporter: Andrew Johnson <andrew_johnson>
Component: CoreAssignee: Project Inbox <mat.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Andrew Johnson CLA 2010-07-20 05:12:09 EDT
Ignoring result of 'Top Components' due to Object 0x2aaabf9e31a0 not found.
org.eclipse.mat.SnapshotException: Object 0x2aaabf9e31a0 not found.
at org.eclipse.mat.parser.internal.SnapshotImpl.mapAddressToId(SnapshotImpl.java:1451)
at org.eclipse.mat.snapshot.model.ObjectReference.getObjectId(ObjectReference.java:56)
at org.eclipse.mat.parser.model.AbstractObjectImpl.resolveValue(AbstractObjectImpl.java:237)
at org.eclipse.mat.inspections.collections.CollectionUtil$Info.getSize(CollectionUtil.java:92)
at org.eclipse.mat.inspections.collections.CollectionsBySizeQuery.execute(CollectionsBySizeQuery.java:104)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.snapshot.query.SnapshotQuery.execute(SnapshotQuery.java:192)
at org.eclipse.mat.snapshot.query.SnapshotQuery.refine(SnapshotQuery.java:202)
at org.eclipse.mat.inspections.component.ComponentReportQuery.addEmptyCollections(ComponentReportQuery.java:434)
at org.eclipse.mat.inspections.component.ComponentReportQuery.execute(ComponentReportQuery.java:108)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.snapshot.query.SnapshotQuery.execute(SnapshotQuery.java:192)
at org.eclipse.mat.inspections.component.TopComponentsReportQuery.execute(TopComponentsReportQuery.java:66)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.query.registry.CommandLine.execute(CommandLine.java:93)
at org.eclipse.mat.report.internal.QueryPart.execute(QueryPart.java:96)
at org.eclipse.mat.report.TestSuite.execute(TestSuite.java:131)
at org.eclipse.mat.report.internal.RunRegisterdReport.execute(RunRegisterdReport.java:50)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.ui.QueryExecution$ExecutionJob.run(QueryExecution.java:174)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

The problem occurs because a field contains an address of an unknown object. The way the DTFJ parser works is that all objects and classes are found initially and are given ids then the outbound references are built. Any unknown outbound refs are ignored, but they are visible as addresses, not ids when an object is inspected.
Comment 1 Andrew Johnson CLA 2010-07-20 05:15:37 EDT
A first step is to improve the error message. The ObjectReference.getObjectId() method throws an exception, and doesn't return <0, so we need to catch the exception and rethrow.

Ignoring result of 'Top Components' due to Field 'map' of 'java.util.HashSet @ 0x2aaabf525450' contains an illegal object reference: 0x2aaabf9e31a0
Comment 2 Andrew Johnson CLA 2010-07-20 10:10:52 EDT
Catching the exception in CollectionsBySizeQuery just leads to another exception later.

java.lang.ClassCastException: org.eclipse.mat.parser.model.PrimitiveArrayImpl incompatible with org.eclipse.mat.snapshot.model.IObjectArray
	at org.eclipse.mat.inspections.collections.CollectionUtil$Info.getBackingArray(CollectionUtil.java:231)
	at org.eclipse.mat.inspections.collections.CollectionFillRatioQuery.getFillRatio(CollectionFillRatioQuery.java:128)
	at org.eclipse.mat.inspections.collections.CollectionFillRatioQuery.execute(CollectionFillRatioQuery.java:116)
	at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
	at org.eclipse.mat.snapshot.query.SnapshotQuery.execute(SnapshotQuery.java:192)
	at org.eclipse.mat.snapshot.query.SnapshotQuery.refine(SnapshotQuery.java:202)
	at org.eclipse.mat.inspections.component.ComponentReportQuery.addCollectionFillRatios(ComponentReportQuery.java:532)
	at org.eclipse.mat.inspections.component.ComponentReportQuery.execute(ComponentReportQuery.java:115)
	at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
	at org.eclipse.mat.snapshot.query.SnapshotQuery.execute(SnapshotQuery.java:192)
	at org.eclipse.mat.inspections.component.TopComponentsReportQuery.execute(TopComponentsReportQuery.java:66)
	at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
	at org.eclipse.mat.query.registry.CommandLine.execute(CommandLine.java:93)
	at org.eclipse.mat.report.internal.QueryPart.execute(QueryPart.java:96)
	at org.eclipse.mat.report.TestSuite.execute(TestSuite.java:131)
	at org.eclipse.mat.report.internal.RunRegisterdReport.execute(RunRegisterdReport.java:50)
	at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
	at org.eclipse.mat.ui.QueryExecution$ExecutionJob.run(QueryExecution.java:174)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 3 Andrew Johnson CLA 2010-07-20 11:39:39 EDT
Here is another exception to be handled.

org.eclipse.mat.SnapshotException: Field table of java.util.HashMap @ 0x2aaaafee0370 contains int[20] @ 0x2aaaafee0988 instead of an array of objects as a backing array
at org.eclipse.mat.SnapshotException.<init>(SnapshotException.java:46)
at org.eclipse.mat.inspections.collections.CollectionUtil$Info.getBackingArray(CollectionUtil.java:232)
at org.eclipse.mat.inspections.collections.MapCollisionRatioQuery.getCollisionRatio(MapCollisionRatioQuery.java:120)
at org.eclipse.mat.inspections.collections.MapCollisionRatioQuery.execute(MapCollisionRatioQuery.java:105)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.snapshot.query.SnapshotQuery.execute(SnapshotQuery.java:192)
at org.eclipse.mat.snapshot.query.SnapshotQuery.refine(SnapshotQuery.java:202)
at org.eclipse.mat.inspections.component.ComponentReportQuery.addHashMapsCollisionRatios(ComponentReportQuery.java:626)
at org.eclipse.mat.inspections.component.ComponentReportQuery.execute(ComponentReportQuery.java:148)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.snapshot.query.SnapshotQuery.execute(SnapshotQuery.java:192)
at org.eclipse.mat.inspections.component.TopComponentsReportQuery.execute(TopComponentsReportQuery.java:66)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.query.registry.CommandLine.execute(CommandLine.java:93)
at org.eclipse.mat.report.internal.QueryPart.execute(QueryPart.java:96)
at org.eclipse.mat.report.TestSuite.execute(TestSuite.java:131)
at org.eclipse.mat.report.internal.RunRegisterdReport.execute(RunRegisterdReport.java:50)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.ui.QueryExecution$ExecutionJob.run(QueryExecution.java:174)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)