Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315835 - NPE in DisassemblyPart
Summary: NPE in DisassemblyPart
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 7.0   Edit
Assignee: Warren Paul CLA
QA Contact: Pawel Piech CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-04 16:17 EDT by Warren Paul CLA
Modified: 2011-05-12 16:46 EDT (History)
5 users (show)

See Also:


Attachments
patch (947 bytes, patch)
2010-06-04 16:19 EDT, Warren Paul CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Warren Paul CLA 2010-06-04 16:17:28 EDT
I just updated to HEAD and started seeing an NPE frequently when viewing the disassembly view.

The fix is simple - I'll attach it shortly.
Comment 1 Warren Paul CLA 2010-06-04 16:19:05 EDT
Created attachment 171169 [details]
patch
Comment 2 Warren Paul CLA 2010-06-04 16:19:35 EDT
It would be good to get this into RC4 if it's not too late.
Comment 3 John Cortell CLA 2010-06-04 16:54:30 EDT
+1. Would need to take a closer look to understand if previousPos being null is an expected state or not, but avoiding the NPE is certainly something we need to get in for Helios since you're actually experiencing it.
Comment 4 Warren Paul CLA 2010-06-04 17:15:46 EDT
I don't completely understand the logic in there, but org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument.getModelPosition(int) returns null every time for me when the disassembly view is first shown, e.g. first debug session after starting the IDE, or if you close and reopen the disassembly view.
Comment 5 John Cortell CLA 2010-06-04 17:26:06 EDT
(In reply to comment #4)
> I don't completely understand the logic in there, but
> org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument.getModelPosition(int)
> returns null every time for me when the disassembly view is first shown, e.g.
> first debug session after starting the IDE, or if you close and reopen the
> disassembly view.

Yeah. Toni's the expert on that logic, so he's the best person to determine whether there's a deeper issue here or not. But avoiding the NPE is must-have short term fix.
Comment 6 Warren Paul CLA 2010-06-04 19:27:29 EDT
Committed the patch to HEAD.
Comment 8 Marc Khouzam CLA 2010-06-04 21:02:45 EDT
I don't know this code so this may be a stupid comment.

Do you guys feel confident that the solution should be

  } else if (previousPos == null || !previousPos.fValid) {
    onTop = true;
  }

and not

  } else if (previousPos != null && !previousPos.fValid) {
    onTop = true;
  }
Comment 9 Anton Leherbauer CLA 2010-06-07 03:02:09 EDT
It would be good to have the stack trace of the NPE.
Normally, DisassemblyDocument.getModelPosition(int) should not return null for a valid position (provided the model is consistent), so the position must be invalid (that's where the stack trace would come in handy).
I think the correct fix should be to simply return from the method without trying to reveal an invalid offset which might in turn trigger another exception from the viewer.