Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorJohn Cortell2008-11-11 14:44:45 +0000
committerJohn Cortell2008-11-11 14:44:45 +0000
commitdf7a53947005c495ca27fd4614bd077d86eb4d34 (patch)
tree9efe0821d12ce3c5056aa5d5d16832a7078bb4d4 /debug
parent172288ff755f4a053dec857722453f2b55a0123c (diff)
downloadorg.eclipse.cdt-df7a53947005c495ca27fd4614bd077d86eb4d34.tar.gz
org.eclipse.cdt-df7a53947005c495ca27fd4614bd077d86eb4d34.tar.xz
org.eclipse.cdt-df7a53947005c495ca27fd4614bd077d86eb4d34.zip
Fixed 254888. Fixed rare-case scenario where NPE results in CDebugTarget handling a thread suspended event. Also adjusted code to not assume that a CThread has a non-null ICDIThread reference (used to be the case, but no longer true with introduction of ICDIDisposable support). Finally, removed redundancy in findThread methods.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java37
1 files changed, 23 insertions, 14 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
index 6611224ab32..f4b6634e596 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
@@ -1275,12 +1275,26 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private void handleThreadTerminatedEvent( ICDIDestroyedEvent event ) {
ICDIThread cdiThread = (ICDIThread)event.getSource();
- CThread thread = findThread( cdiThread );
- if ( thread != null ) {
- getThreadList().remove( thread );
- thread.terminated();
- thread.fireTerminateEvent();
- }
+ List threads = getThreadList();
+ List<CThread> threadsToRemove = new ArrayList<CThread>(1);
+ for(int i = 0; i < threads.size(); i++) {
+ CThread cthread = (CThread)threads.get(i);
+ // It's possible CThread has handled the thread-terminated event
+ // before us (by appearing first in the EventManager)
+ // and has disassociated itself from the ICDIThread.
+ // So handle any disassociated CThreads we find. Chances are
+ // there's only one and it's the one we got the terminated event
+ // for. See bugzilla 254888.
+ ICDIThread cdithread = cthread.getCDIThread();
+ if (cdithread == null || cdithread.equals(cdiThread)) {
+ threadsToRemove.add(cthread);
+ }
+ }
+ for (CThread cthread : threadsToRemove) {
+ threads.remove(cthread);
+ cthread.terminated();
+ cthread.fireTerminateEvent();
+ }
}
/**
@@ -1290,19 +1304,14 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* @return the associated model thread
*/
public CThread findThread( ICDIThread cdiThread ) {
- List threads = getThreadList();
- for( int i = 0; i < threads.size(); i++ ) {
- CThread t = (CThread)threads.get( i );
- if ( t.getCDIThread().equals( cdiThread ) )
- return t;
- }
- return null;
+ return findThread(getThreadList(), cdiThread);
}
public CThread findThread( List threads, ICDIThread cdiThread ) {
for( int i = 0; i < threads.size(); i++ ) {
CThread t = (CThread)threads.get( i );
- if ( t.getCDIThread().equals( cdiThread ) )
+ ICDIThread thisCdiThread = t.getCDIThread();
+ if ( thisCdiThread != null && thisCdiThread.equals( cdiThread ) )
return t;
}
return null;

Back to the top