Bug 167426 - InstructionPointerContext keeps reference to closed editor
Summary: InstructionPointerContext keeps reference to closed editor
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on: 69289 184027
Blocks:
  Show dependency tree
 
Reported: 2006-12-11 10:01 EST by Dani Megert CLA
Modified: 2007-04-30 15:51 EDT (History)
0 users

See Also:


Attachments
Fix (19.81 KB, patch)
2007-04-25 13:23 EDT, Curtis Windatt CLA
no flags Details | Diff
Patch for tests (work in progress) (53.45 KB, patch)
2007-04-27 18:57 EDT, Curtis Windatt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2006-12-11 10:01:38 EST
I20061129-1340

Found while looking at bug 166761: take the example from that bug but don't step into selection. Instead simply close the editor.
==> InstructionPointerContext references the closed editor and hence an instance stays around until the debugger is terminated.
Comment 1 Darin Wright CLA 2007-04-10 09:33:39 EDT
Investigate for 3.3
Comment 2 Darin Wright CLA 2007-04-19 12:17:56 EDT
Dani suggest that we might try a ISaveablesLifecycleListener rather than a part listener.

via: (ISaveablesLifecycleListener)editor.getSite().getService(ISaveablesLifecycleListener.class)
Comment 3 Dani Megert CLA 2007-04-19 12:25:05 EDT
>Dani suggest that we might try a ISaveablesLifecycleListener rather than a part
>listener.
Just to be clear: I would recommend to use the part listener ;-)
Comment 4 Curtis Windatt CLA 2007-04-25 13:23:17 EDT
Created attachment 64897 [details]
Fix

Fix clears out no longer needed annotations when the editor is closed or it's input changes.  The way the pointers were cached has been changed to improve performance (mapping of debug targets and threads was removed, mapping of editors to annotations was added).

Issues:
1) Concurrent modification exception was occuring occasionally.  See Bug 69289, and Bug 184027.  To try and avoid this, the StackFrameSourceDisplayAdapter was altered to ensure that annotation model changes were being done in the ui thread.  The problem still occurs, but it very difficult to reproduce.  One possible solution would be synchronize on the AnnotationModel object, but this risks deadlock.

2) To improve performance, we should consider using the replace method on the annotation model when removing groups of annotations (target or thread resumed).  Using one call to replace is faster than removing each one individually.

3) Tests should be added to test this manager.
Comment 5 Curtis Windatt CLA 2007-04-27 16:12:52 EDT
Fixed in HEAD.

See InstructionPointerContext, InstructionPointerManager, StackFrameSourceDisplayAdapter, InstructionPointerTests.

I will be adding a new test suite to fully test the manager in the near future once a couple transient failures in them can be tracked down.
Comment 6 Curtis Windatt CLA 2007-04-27 16:13:10 EDT
Darin please verify
Comment 7 Darin Wright CLA 2007-04-27 16:38:18 EDT
Verified.
Comment 8 Curtis Windatt CLA 2007-04-27 18:57:39 EDT
Created attachment 65286 [details]
Patch for tests (work in progress)

The patch adds a new test suite to test InstructionPointerManager.

As they are still a work in progress, they print a lot of text to the console and the automated suite has been changed to just run the new suite.

Things to fix:

1) In rare cases, at the end of the test without editor reuse, immediately after all the editors have been closed, a new annotation is added.  This puts the final IPC count at 1, not 0, failing the test.

2) In both tests (with and without editor reuse) selecting the second stack frame in the same thread will sometimes not add the annotation.  This results in a long wait and a failed test.

3) In the test without editor reuse, the closing of the editor containing ThreadStack will sometimes wait (the wait is not stopped early by notifyAll.

4) A part listener is added to listen for input changes, it is not currently removed.
Comment 9 Curtis Windatt CLA 2007-04-30 15:51:17 EDT
Tests were added to HEAD, but not included in the automated tests as they occasionally fail.