Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334329 - Launch is not marked as 'terminated' when program exits
Summary: Launch is not marked as 'terminated' when program exits
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-13 18:30 EST by Nobody - feel free to take it CLA
Modified: 2011-05-19 20:44 EDT (History)
3 users (show)

See Also:
nobody: iplog-


Attachments
Fix. (3.12 KB, patch)
2011-01-13 18:30 EST, Nobody - feel free to take it CLA
no flags Details | Diff
Modified patch. (1.48 KB, patch)
2011-01-26 13:52 EST, Nobody - feel free to take it CLA
nobody: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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