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

Bug 315835

Summary: NPE in DisassemblyPart
Product: [Tools] CDT Reporter: Warren Paul <warren.paul>
Component: cdt-debug-dsfAssignee: Warren Paul <warren.paul>
Status: RESOLVED FIXED QA Contact: Pawel Piech <pawel.1.piech>
Severity: normal    
Priority: P3 CC: aleherb+eclipse, john.cortell, ken.ryall, marc.khouzam, pawel.1.piech
Version: 7.0   
Target Milestone: 7.0   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch cdtdoug: iplog-

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.