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

Bug 334329

Summary: Launch is not marked as 'terminated' when program exits
Product: [Tools] CDT Reporter: Nobody - feel free to take it <nobody>
Component: cdt-debug-dsf-gdbAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle, pawel.1.piech
Version: 8.0Flags: nobody: iplog-
Target Milestone: 8.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Fix.
none
Modified patch. nobody: iplog-

Description Nobody - feel free to take it CLA 2011-01-13 18:30:56 EST
Created attachment 186797 [details]
Fix.

This problem is caused by the race condition between the shutdown sequence and the threads that monitor the inferior and gdb processes. 

The easiest way to reproduce it is to set breakpoints: 
1. at the beginning of "handleCompleted()" call in "GdbLaunch.shutdownSession()"
2. at the beginning of "RuntimeProcess.terminated()"
Start a session and let it run to the end. Both breakpoints will hit at the same time. 
Resume the thread for "handleCompleted()" first and then two other threads.
The launch's label is not marked as terminated and the toolbar actions are not updated: "Terminate" is enabled and "RemoveAllTerminated" is disabled.
Comment 1 Marc Khouzam CLA 2011-01-13 19:22:35 EST
Nice!

Half of the fix is in DSF so Pawel should probably have a look.
Comment 2 Nobody - feel free to take it CLA 2011-01-24 12:45:20 EST
Pawel, please take a look.
Comment 3 Nobody - feel free to take it CLA 2011-01-26 11:34:33 EST
Marc, not sure what to do with this patch. Pawel seems to be busy. 
I can modify the patch by fixing it for DSF/GDB only, or we can go ahead with the existing one.
Comment 4 Marc Khouzam CLA 2011-01-26 11:47:51 EST
(In reply to comment #3)
> Marc, not sure what to do with this patch. Pawel seems to be busy.
> I can modify the patch by fixing it for DSF/GDB only, or we can go ahead with
> the existing one.

I don't fully understand the delta stuff, so let me ask a couple of questions:

- how come we need to check for DebugEvent.TERMINATE although we also check for LaunchesEvent.Type.TERMINATED?
- if we need to check for DebugEvent.TERMINATE, how come you don't need to set the IModelDelta.CONTENT flag like it is done in the case of LaunchesEvent.Type.TERMINATED?

I think the change is safe, so I think it is ok for DSF.  The worst case is probably some unnecessary refreshes.
Comment 5 Nobody - feel free to take it CLA 2011-01-26 13:52:44 EST
Created attachment 187669 [details]
Modified patch.
Comment 6 Nobody - feel free to take it CLA 2011-01-26 13:55:30 EST
(In reply to comment #4)
> I don't fully understand the delta stuff, so let me ask a couple of questions:
> - how come we need to check for DebugEvent.TERMINATE although we also check for
> LaunchesEvent.Type.TERMINATED?

You're right. I changed the delta part first, to update the launch label, but it didn't fix the actions issue. The GdbLaunch fix is sufficient.
Comment 7 Nobody - feel free to take it CLA 2011-01-26 14:01:09 EST
Applied to the HEAD.
Comment 8 Marc Khouzam CLA 2011-01-26 14:09:06 EST
(In reply to comment #6)
> I changed the delta part first, to update the launch label, but
> it didn't fix the actions issue. The GdbLaunch fix is sufficient.

It's nice when things work out so easily :-)
Comment 9 CDT Genie CLA 2011-01-26 14:23:03 EST
*** cdt cvs genie on behalf of mkhodjai ***
Bug 334329 - Launch is not marked as 'terminated' when program exits.

[*] GdbLaunch.java 1.12 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java?root=Tools_Project&r1=1.11&r2=1.12