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

Bug 318797

Summary: [implementation] Deadlock in SharedASTProvider.getAST() (on breakpoint creation)
Product: [Eclipse Project] JDT Reporter: Andrey Loskutov <loskutov>
Component: TextAssignee: Dani Megert <daniel_megert>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: benno.baumgartner, cameron.bateman, daniel_megert, david_williams, jtk499, markus.kell.r, mikko.tiihonen, raghunathan.srinivasan, remy.suen, victor.zverovich
Version: 3.7Flags: markus.kell.r: review+
Target Milestone: 3.6.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
deadlocked VM dump
none
deadlock with 3.6
none
jstack output for a deadlocked eclipse none

Description Andrey Loskutov CLA 2010-07-03 16:03:05 EDT
Build Identifier: 3.6.0 final

Similar to bug 310396 and bug 302581, this time I've got a deadlock while debugging by simply double-clicking on the vertical editor ruler.

I will attach stack dump. As noticed in bug 302581 comment 3, usual pattern is to check a condition BEFORE calling .wait() method on an object. This time as the UI requested the AST, UI thread got blocked forever, so nobody can call notify()...

Reproducible: Always
Comment 1 Andrey Loskutov CLA 2010-07-03 16:04:00 EDT
Created attachment 173355 [details]
deadlocked VM dump

Dump created with jstack -l.
Comment 2 Carsten Pfeiffer CLA 2010-07-22 08:37:51 EDT
Created attachment 174962 [details]
deadlock with 3.6

A similar deadlock happened here (with Eclipse 3.6).
Comment 3 Dani Megert CLA 2010-07-27 08:51:34 EDT
>I will attach stack dump. As noticed in bug 302581 comment 3, usual pattern is
>to check a condition BEFORE calling .wait() method on an object.
We check isReconcile(...) inside the synchronize and before the wait.

I tried many times to reproduce it on double-click but no luck. The only thing I can see at this point in the code is the possibility that someone unexpectedly (cancel on type is expected) cancels the progress monitor and that the progress monitor state isn't reset correctly. The safest fix for that is to simply not do that check and always set 'fReconciling' to 'false'. While this can theoretically lead to additional AST creation in rare cases, it at least closes the hole. Also, our Java editor open & activation performance/stress tests show no additional AST creation and no regressions.

It would still be great to have steps to reproduce the bug in the UI. Can one of you reproduce it? Can you remember the steps you did just before the deadlock happened (e.g. type, switch editor, ...)?
Comment 4 Andrey Loskutov CLA 2010-07-27 16:32:41 EDT
(In reply to comment #3)
> It would still be great to have steps to reproduce the bug in the UI. Can one
> of you reproduce it? Can you remember the steps you did just before the
> deadlock happened (e.g. type, switch editor, ...)?

Hard to say how to reproduce this. I've got this by debugging Eclipse from Eclipse, and usually I use the same (Java) perspective for the debugging tasks, so that I have debug view, breakpoints etc in my default Java perspective. But except this everything else was "just usual".
Comment 5 Dani Megert CLA 2010-08-02 06:19:14 EDT
*** Bug 321483 has been marked as a duplicate of this bug. ***
Comment 6 Cameron Bateman CLA 2010-08-12 12:27:19 EDT
This is occurring around once a day on my machine.  It seems to occur simply by opening a Java editor.  

This is showstopper for us on Helios if it is widely reproducible among our users.  When is 3.6.1 scheduled?
Comment 7 Dani Megert CLA 2010-08-13 01:46:29 EDT
>When is 3.6.1 scheduled?
September but you can already take one of the maintenance builds towards 3.6.1, e.g. http://download.eclipse.org/eclipse/downloads/drops/M20100811-0800/index.php. This would be very useful in order to tell us whether the fix works for you.
Comment 8 Markus Keller CLA 2010-08-16 13:31:29 EDT
(In reply to comment #7)
> ... but you can already take one of the maintenance builds towards 3.6.1,
> e.g.
> http://download.eclipse.org/eclipse/downloads/drops/M20100811-0800/index.php.
> This would be very useful in order to tell us whether the fix works for you.

This fix has not yet been released for 3.6.1, so it's not yet in an M-build.

But it would be great if you could test it in a 3.7 build, e.g.:
http://download.eclipse.org/eclipse/downloads/drops/S-3.7M1-201008051700/index.php
Comment 9 Dani Megert CLA 2010-08-17 02:25:25 EDT
>This fix has not yet been released for 3.6.1, so it's not yet in an M-build.
Ah right. Sorry about that.
Comment 10 Dani Megert CLA 2010-08-23 05:56:31 EDT
Markus, OK for 3.6.1 RC2?
Comment 11 Markus Keller CLA 2010-08-23 10:53:47 EDT
+1 for releasing ASTProvider 1.74 for 3.6.1.

It's hard to verify without being able to reproduce, but the scenario with the canceled progress monitor sounds plausible, and the fix removes the deadlock opportunity in that case.
Comment 12 Dani Megert CLA 2010-08-24 06:30:51 EDT
Fixed in R3_6_maintenance.
Available in builds >= M20100825-0800.
Comment 13 Dani Megert CLA 2010-08-26 04:14:39 EDT
Verified in code of M20100825-0800.
Comment 14 Dani Megert CLA 2010-09-22 03:24:49 EDT
*** Bug 325927 has been marked as a duplicate of this bug. ***
Comment 15 Dani Megert CLA 2010-09-27 02:26:56 EDT
*** Bug 325927 has been marked as a duplicate of this bug. ***
Comment 16 Dani Megert CLA 2011-01-28 03:21:27 EST
*** Bug 335656 has been marked as a duplicate of this bug. ***
Comment 17 Dani Megert CLA 2011-04-05 09:29:53 EDT
*** Bug 341901 has been marked as a duplicate of this bug. ***
Comment 18 Missing name CLA 2011-06-15 04:58:12 EDT
Created attachment 198002 [details]
jstack output for a deadlocked eclipse

Just happened to me in 

"Eclipse Java EE IDE for Web Developers.

Version: Helios Service Release 2
Build id: 20110218-0911" on a 64-bit Windows 7.

See the attached jstack.txt 

So this should be reopened?
Comment 19 Dani Megert CLA 2011-06-15 04:59:32 EDT
(In reply to comment #18)
> Created attachment 198002 [details]
> jstack output for a deadlocked eclipse
> 
> Just happened to me in 
> 
> "Eclipse Java EE IDE for Web Developers.
> 
> Version: Helios Service Release 2
> Build id: 20110218-0911" on a 64-bit Windows 7.
> 
> See the attached jstack.txt 
> 
> So this should be reopened?
No. There was another bug which we already fixed in 3.7.