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

Bug 334650

Summary: [tests] JUnit test can cause deadlock
Product: [Tools] CDT Reporter: Marc Khouzam <marc.khouzam>
Component: cdt-debug-dsf-gdbAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: cdtdoug, pawel.1.piech, pchuong
Version: 8.0Flags: marc.khouzam: review? (pchuong)
Target Milestone: 8.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fix cdtdoug: iplog-

Description Marc Khouzam CLA 2011-01-18 09:47:53 EST
Created attachment 187002 [details]
Fix

I ran into a deadlock when starting the JUnit tests after the Pin&Clone feature was committed.

From what I can see, the JUnit tests run in their own thread and cause the debug plugins to be loaded from that thread.  At the same time, the JUnit tests launch a debug session which requires the UI thread.  The problem is that the ViewIDCounterManager#init() class has started a UI job which requires the debug plugin to be loaded (to access the PinCloneUtils class).  This creates a deadlock.

I'm not sure if the JUnit tests are supposed to start a launch on a different thread than the UI thread, but since it is only affecting the tests, I'm just going to fix it so that it works.

The fix that works is to remove the need for the UI thread from the JUnit test launch by by-passing the preLaunchCheck from the platform.  That check should have been by-passed anyway as it serves no purpose for tests.

The attached patch does this
Comment 1 Marc Khouzam CLA 2011-01-18 09:55:16 EST
Committed the patch to HEAD.
Patrick, can you review?
Comment 2 CDT Genie CLA 2011-01-18 10:23:04 EST
*** cdt cvs genie on behalf of mkhouzam ***
Bug 334650: [tests] JUnit test can cause deadlock

[*] TestLaunchDelegate.java 1.4 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/launching/TestLaunchDelegate.java?root=Tools_Project&r1=1.3&r2=1.4
Comment 3 Patrick Chuong CLA 2011-01-18 10:53:07 EST
Marc, with 334651 fixed. I don't think this is required.
Comment 4 Marc Khouzam CLA 2011-01-18 13:58:55 EST
(In reply to comment #3)
> Marc, with 334651 fixed. I don't think this is required.

You are right.  However, I think the fix makes the JUnit test a little leaner and quicker, so I'd prefer to keep it in in an attempt to have the JUnit test run faster.