Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364550 - Deadlock on startup
Summary: Deadlock on startup
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Team (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Linux-GTK
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Platform Team Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on: 239230
Blocks:
  Show dependency tree
 
Reported: 2011-11-23 04:32 EST by James Blackburn CLA
Modified: 2019-10-08 10:50 EDT (History)
3 users (show)

See Also:


Attachments
deadlock backtrace (25.57 KB, text/plain)
2011-11-23 04:32 EST, James Blackburn CLA
no flags Details
Testcase (760 bytes, text/x-java)
2014-05-21 04:22 EDT, Craig CLA
no flags Details
My improved workaround (403 bytes, text/x-java)
2014-05-21 04:34 EDT, Craig CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Blackburn CLA 2011-11-23 04:32:10 EST
Created attachment 207405 [details]
deadlock backtrace

Installed Features:
org.eclipse.team.svn_0.7.9.I20110819-1700
org.polarion.eclipse.team.svn.connector_2.2.2.I20110819-1700
org.polarion.eclipse.team.svn.connector.svnkit15_2.2.2.I20110819-1700
org.polarion.eclipse.team.svn.connector.svnkit16_2.2.2.I20110819-1700
org.polarion.eclipse.team.svn.m2eclipse_1.0.2.I20110227-1700

Using the latest Indigo release (AFAICS), I get a deadlock every time I startup a certain workspace.
Comment 1 Alexander Gurov CLA 2012-01-28 14:12:17 EST
After careful consideration of the situation and the provided stacktraces the only conclusion is that there are no deadlocks. It seeme like some time consuming operation is in progress instead. The only related thing that comes to mind is that since the time of the report there were some performance improvements (related to the JDT support and refreshing resources) made in Subversive that probably (but no guarantee) could help the situation.
Comment 2 James Blackburn CLA 2012-01-30 13:16:07 EST
Can you explain why this isn't a deadlock?

syncExec isn't processed during earlyStartup (which is where the main thread is).  The result is:
 main thread (UI): holds UI ; trying to acquire ws lock
 Worker-0 : holds WS lock ; trying to syncExec onto the UI

=> Deadlock.
Comment 3 James Blackburn CLA 2012-01-30 13:17:15 EST
Note this may be a team issue, rather than a SVNKit issue.

However if I have my history view at the top, and shutdown the WS, then I can't start the worskpace again.  (A workaround is to delete the securestorage file, disabling the password prompt...)
Comment 4 Alexander Gurov CLA 2012-01-30 13:55:13 EST
The point is that the main thread awaits team provider being loaded, while team provider loading is stumbled upon a class loading and awaits for closing of the secure storage password prompt dialog called somewhere deep inside the Eclipse Platform class loader workflow (I do not understand why, since I know nothing of the Eclipse Platform class loader implementation).
It means that IDE was locked not due to the Subversive code:

public void start(BundleContext context) throws Exception {
	super.start(context);
	this.tracker = new ServiceTracker(context, IProxyService.class.getName(), null); // <---- locked here on class loading

but due to class loader implementation.

I could have tried to move this report somewhere else (Platform Component), but there are few other points present too:

1) There is a high chance somewhere around your visually "locked" Eclipse IDE instance was present a password prompt window, for whatever the reason it was called.

2) There are no threads in BLOCKED state. There are no cross-locks in Subversive (the only thread running Subversive code is worker-0, which is just plug-in startup) or Platform code.

3) On the other hand it seems there are at least two actively running IO streams (they're not in IO-wait mode), which could cause slow startup for the workspace.

Considering all those reasons I've closed the report.

P.S.
It is definitely not the Subversive issue, but it does not seem as Team issue either. Also considering thread's states it does not seem like a "deadlock" issue at all. It more seems like "dialog opened behind the main window" issue.
Comment 5 James Blackburn CLA 2012-01-30 14:11:52 EST
Ok. I do understand how the eclipse platform and ui interact, and trust me this a real deadlock. 

Neither the main UIthread, nor the worker thread can make progress because they each require a resource held by the other, as outlined in my previous comment. The other threads are unimportant to the deadlock.

Moving to platform as its history view and team.
Comment 6 Alexander Gurov CLA 2012-01-30 14:44:03 EST
(In reply to comment #5)
Yes, I get what is it you're telling me. Looks like it'll be better for me to get a little more sleep time this week. :)
Comment 7 Craig CLA 2014-05-21 04:22:41 EDT
Created attachment 243321 [details]
Testcase
Comment 8 Craig CLA 2014-05-21 04:23:29 EDT
I was about to log this bug. I'm experiencing a deadlock (well more specifically a "LiveLock") when the workbench starts up for an RCP application (version 4.3.2, but I think this problem exists in older version too) that I'm working on. It only happens on gtk and after debugging it I found the problem. 

org.eclipse.ui.application.WorkbenchAdvisor.java class has a method called:
 public boolean openWindows(){... }

And this method tells the main method to fire off a thread to do work and call display.wake() when its done. In the meantime the main thread calls display.sleep() in while loop waiting for this thread to finish. The main thread never gets past this point ... because the "wake" signal was never picked up.

looking in the sleep() method there is a comment:
/*
* Bug in GTK. For some reason, g_main_context_wakeup() may 
* fail to wake up the UI thread from the polling function.
* The fix is to sleep for a maximum of 50 milliseconds.
*/
and what it does it resets the "wake" flag that was raised by the wake thread ... 

I've attached a small test class that will hopefully prove this livelock.
Comment 9 Craig CLA 2014-05-21 04:27:47 EDT
I have 2 workarounds:
1) Override that openWindows method and add a sleep just before the display.wake gets called in the thread. (1000ms ... it really sucks)
2) Start another rcp application instance to unstuck the first one ... (this sucks too)
Comment 10 Craig CLA 2014-05-21 04:34:53 EDT
Created attachment 243322 [details]
My improved workaround

Instead of the sleep workaround I now do the following to workaround the live lock
Comment 11 Eclipse Genie CLA 2019-03-03 00:09:13 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 12 Lars Vogel CLA 2019-10-08 10:50:25 EDT
This bug was marked as stalebug a while ago. Marking as wontfix.

If this report is still relevant for the current release, please
reopen and remove the stalebug whiteboard tag.