Bug 325426 - [thread sync] Deadlock when using "suspend VM" breakpoints
Summary: [thread sync] Deadlock when using "suspend VM" breakpoints
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Sarika Sinha CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 401421 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-16 05:44 EDT by Mauro Molinari CLA
Modified: 2024-03-09 15:20 EST (History)
6 users (show)

See Also:
sarika.sinha: review? (Michael_Rennie)


Attachments
Full thread dump (from jVisualVM) (49.43 KB, text/plain)
2010-09-16 05:49 EDT, Mauro Molinari CLA
no flags Details
JDI Thread resume() method to resume Debug Target as before (686 bytes, patch)
2014-04-23 02:47 EDT, Sarika Sinha CLA
no flags Details | Diff
JDI Thread resume() method to resume Debug Target as before (1.08 KB, patch)
2014-04-23 04:00 EDT, Sarika Sinha CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2010-09-16 05:44:53 EDT
Build Identifier: I20100608-0911

I'm trying to do a debug session with a "suspend vm" breakpoint. However Eclipse keeps on going to a deadlock. Here are the stack traces of the threads in deadlock:

Name: Worker-9
State: BLOCKED on org.eclipse.jdt.internal.debug.core.model.JDIThread@185e093f owned by: Worker-3
Total blocked: 701  Total waited: 756

Stack trace: 
org.eclipse.jdt.internal.debug.core.model.JDIThread.getBreakpoints(JDIThread.java:371)
org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getThreadText(JDIModelPresentation.java:308)
org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getText(JDIModelPresentation.java:244)
org.eclipse.debug.internal.ui.LazyModelPresentation.getText(LazyModelPresentation.java:185)
org.eclipse.debug.internal.ui.DelegatingModelPresentation.getText(DelegatingModelPresentation.java:158)
org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider.getLabel(DebugElementLabelProvider.java:35)
org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider.getLabel(ElementLabelProvider.java:312)
org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider.retrieveLabel(ElementLabelProvider.java:215)
org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelUpdater.run(ElementLabelProvider.java:160)
org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelJob.run(ElementLabelProvider.java:74)
org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Name: Worker-3
State: BLOCKED on org.eclipse.jdt.internal.debug.core.model.JDIThread@2237ed25 owned by: Worker-4
Total blocked: 149  Total waited: 258

Stack trace: 
org.eclipse.jdt.internal.debug.core.model.JDIThread.resumedByVM(JDIThread.java:1623)
org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.resumeThreads(JDIDebugTarget.java:1308)
org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.cancelSuspendByBreakpoint(JDIDebugTarget.java:1347)
org.eclipse.jdt.internal.debug.core.model.JDIThread.completeBreakpointHandling(JDIThread.java:1171)
   - locked org.eclipse.jdt.internal.debug.core.model.JDIThread@185e093f
org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint.eventSetComplete(JavaBreakpoint.java:311)
org.eclipse.jdt.internal.debug.core.EventDispatcher.dispatch(EventDispatcher.java:204)
org.eclipse.jdt.internal.debug.core.EventDispatcher.access$0(EventDispatcher.java:104)
org.eclipse.jdt.internal.debug.core.EventDispatcher$1.run(EventDispatcher.java:250)
org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Name: Worker-4
State: BLOCKED on org.eclipse.jdt.internal.debug.core.model.JDIThread@185e093f owned by: Worker-3
Total blocked: 160  Total waited: 276

Stack trace: 
org.eclipse.jdt.internal.debug.core.model.JDIThread.resumedByVM(JDIThread.java:1623)
org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.resumeThreads(JDIDebugTarget.java:1308)
org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.cancelSuspendByBreakpoint(JDIDebugTarget.java:1347)
org.eclipse.jdt.internal.debug.core.model.JDIThread.completeBreakpointHandling(JDIThread.java:1171)
   - locked org.eclipse.jdt.internal.debug.core.model.JDIThread@2237ed25
org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint.eventSetComplete(JavaBreakpoint.java:311)
org.eclipse.jdt.internal.debug.core.EventDispatcher.dispatch(EventDispatcher.java:204)
org.eclipse.jdt.internal.debug.core.EventDispatcher.access$0(EventDispatcher.java:104)
org.eclipse.jdt.internal.debug.core.EventDispatcher$1.run(EventDispatcher.java:250)
org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

I'm going to attach a full ThreadDump

Reproducible: Always

Steps to Reproduce:
1. debug a JUnit4 test case, setting up a breakpoint that suspends the VM
Comment 1 Mauro Molinari CLA 2010-09-16 05:49:04 EDT
Created attachment 179008 [details]
Full thread dump (from jVisualVM)
Comment 2 Darin Wright CLA 2010-09-16 10:24:56 EDT
Do you recall if you had 2 breakpoints configured to suspend the VM, perhaps with conditions?
Comment 3 Mauro Molinari CLA 2010-09-16 10:29:15 EDT
I'm almost sure I had just one with "suspend VM" AND a condition. The other breakpoints were with "suspend thread", with or without conditions.
Comment 4 Heiko Böttger CLA 2013-04-19 06:15:06 EDT
Today I got the same Problem with 3.8.2 and slowing this deadlocks driving me crazy. 

I have multiple breakpoints, some are conditional, all are configured to suspend the vm. After the vm was stopped, I pressed resume and ended up in a state, where some of the threads where suspended and others resumed. 

If I press the resume button again, this will result in a deadlock. Between JDTThread.resumedByVM and JDTThread.suspendedByVM. This brings me to next bad thing, the whole workspace has to be rebuilt after the crash and all breakpoints created since the last proper shutdown are lost.
Comment 5 Michael Rennie CLA 2013-04-19 09:25:45 EDT
*** Bug 401421 has been marked as a duplicate of this bug. ***
Comment 6 Thomas Klambauer CLA 2013-10-29 07:41:03 EDT
I was debugging a similar problem, where Thread#run would not be called after a thread.start, which might lead to a deadlock if you do a thread.join after calling the start.

I can reproduce with my machine that a thread is not started when previously a "suspend vm" breakpoint was hit.

I very seriously suspect that this VM bug is the cause for my problem:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6526033

Maybe this is a cause also for this bug here?
Comment 7 Sarika Sinha CLA 2014-04-07 07:29:57 EDT
Trying to create low level object locks to avoid synchronized method locks to minimize racing condition.
Comment 8 Sarika Sinha CLA 2014-04-09 04:44:43 EDT
I am not able to reproduce this with one break point having Suspend VM condition. 
It reproduced easily with 2 breakpoints having Suspend VM conditions with Junits.

If someone can provide an example to reproduce deadlock with one breakpoint having Suspend VM condition, it will help.
Comment 9 Sarika Sinha CLA 2014-04-10 03:28:38 EDT
I tried creating a couple of ( 4 actually)  Reentrant locks, removed the Synchronized tag from the methods and used the localized locks. I observe that it helps in some scenarios but not all the time, some threads start up but some are still in suspended state. It makes me think that it might be related to VM bug as mentioned in Comment#6.

On the other hand I found a workaround to make it work and avoid the deadlock. After the breakpoint is hit, if we press the Resume button when  the particular thread is selected, we have a chance of getting into deadlock. But if we select the main thread like  org.eclipse.equinox.launcher.Main  and then select Resume, there is no deadlock. 

Has anyone tried this workaround ?
Comment 10 Sarika Sinha CLA 2014-04-11 07:53:41 EDT
Resuming from main thread works fine with Oracle and IBM both the JREs.
Comment 11 Michael Rennie CLA 2014-04-21 10:37:18 EDT
(In reply to Sarika Sinha from comment #10)
> Resuming from main thread works fine with Oracle and IBM both the JREs.

Could be related to the fix for bug 372030, where we added support for resuming threads individually.
Comment 12 Sarika Sinha CLA 2014-04-23 02:47:55 EDT
Created attachment 242215 [details]
JDI Thread resume() method to resume Debug Target as before

!isSuspended() check was added before resuming Debug Target as part of Bug 37203. Removing this check I was able to run through 2 or more breakpoints with Suspend VM option.

I was not able to reproduce Deadlock (with and without the patch ) with a single breakpoint having suspend VM condition.
Comment 13 Sarika Sinha CLA 2014-04-23 04:00:43 EDT
Created attachment 242218 [details]
JDI Thread resume() method to resume Debug Target as before

Copyright added
Comment 14 Dani Megert CLA 2014-10-08 10:41:45 EDT
(In reply to Sarika Sinha from comment #12)
> Created attachment 242215 [details] [diff]
> JDI Thread resume() method to resume Debug Target as before
> 
> !isSuspended() check was added before resuming Debug Target as part of Bug
> 37203. Removing this check I was able to run through 2 or more breakpoints
> with Suspend VM option.

And is bug 372030 still fixed with this change?
Comment 15 Sarika Sinha CLA 2014-10-09 02:05:14 EDT
(In reply to Dani Megert from comment #14)

> And is bug 372030 still fixed with this change?


I am able to resume individual threads after applying the patch as well.
Comment 16 Markus Keller CLA 2014-10-14 10:14:58 EDT
(In reply to Sarika Sinha from comment #15)
> (In reply to Dani Megert from comment #14)
> 
> > And is bug 372030 still fixed with this change?
> 
> 
> I am able to resume individual threads after applying the patch as well.

Bug 372030 was about resuming an individual thread after the whole VM was suspended. E.g. run bug 372030 comment 4, suspend the whole VM ("xy.Try at *"), and then try to resume thread "Try-0". This works without your patch, but doesn't work any more with it.

What are the steps for reproducing the problem you're trying to fix?
Comment 17 Sarika Sinha CLA 2016-05-10 05:21:43 EDT
(In reply to Markus Keller from comment #16)
> (In reply to Sarika Sinha from comment #15)
> > (In reply to Dani Megert from comment #14)
> > 
> > > And is bug 372030 still fixed with this change?
> > 
> > 
> > I am able to resume individual threads after applying the patch as well.
> 
> Bug 372030 was about resuming an individual thread after the whole VM was
> suspended. E.g. run bug 372030 comment 4, suspend the whole VM ("xy.Try at
> *"), and then try to resume thread "Try-0". This works without your patch,
> but doesn't work any more with it.
> 
> What are the steps for reproducing the problem you're trying to fix?

I tried the bug 372030 comment 4 code, and I was able to resume thread "Try-0" after the patch as well. Also before the patch it never moves to Try-1, Try2 and Try-3 even after we resume but with patch it does.

What we are trying to fix is a case when we have more than 1 breakpoint with suspend VM condition being hit.
Comment 18 Sarika Sinha CLA 2017-05-18 03:33:13 EDT
Not working on this.
Comment 19 Eclipse Genie CLA 2020-03-23 17:07:17 EDT
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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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 20 Mauro Molinari CLA 2020-03-24 04:14:13 EDT
I think this is worth a new look, it has been reproduced, there's a pending review request and a proposed patch (which seems to work, not clear whether or not it breaks something else).
Comment 21 Eclipse Genie CLA 2022-03-15 12:46:25 EDT
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 22 Eclipse Genie CLA 2024-03-09 15:20:31 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.