This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 257412 - Debugger deadlocks if breakpoint configured to Suspend All Threads
Summary: Debugger deadlocks if breakpoint configured to Suspend All Threads
Status: VERIFIED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P1 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2016-01-05 09:24 UTC by _ gtzabari
Modified: 2016-02-04 12:55 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2016-01-05 09:24:17 UTC
Product Version: NetBeans IDE Dev (Build 201512240002)
Java: 1.8.0_66; Java HotSpot(TM) 64-Bit Server VM 25.66-b17
Runtime: Java(TM) SE Runtime Environment 1.8.0_66-b17
System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

I have flagged this issue with a P1 because it is a regression and because some applications cannot be debugged using "Suspend: Breakpoint thread" (in applications where the state of one thread causes another thread to do the wrong thing).

Testcase:

public class DebuggerDeadlock {

    public static void main(String[] args) {
        for (int i = 0; i < 100; ++i) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    new DebuggerDeadlock().run();
                }
            }).start();
        }
    }

    public void run() {
        SomeClass base = new SomeClass();
        base.someMethod();
    }

    public class SomeClass {

        public void someMethod() {
            System.out.println("one");
        }
    }
}

Repro steps:

1. Set a breakpoint on the line "SomeClass base = new SomeClass();"
2. Configure the breakpoint to "Suspend: All threads" and enable "Default for New Breakpoints"
3. Start debugging session (CTRL+F5)
4. With the Debugging tab open on the left, hit F5 (continue) 10 times (we are making sure enough threads are running in the Debugging tab).
5. Now, step over (F8) "SomeClass base = new SomeClass()" and step into (F7) "base.someMethod()"

When running the above steps, I usually get a deadlock in step 5: the thread you were in will read "running" in the Debugging tab but will never enter someMethod().

Other times, I will get a deadlock on step 4 (hitting F5). Other times I get it when stepping over (F8) code in step 5.

This bug is intermittent but occurs very frequently. Please let me know whether you are able to reproduce it on your end.

This bug seems to be specific to "Suspend: All threads". I have not been able to reproduce it for "Suspend: Breakpoint thread".
Comment 1 Martin Entlicher 2016-01-05 13:47:11 UTC
Reproduced, investigating...
Comment 2 Martin Entlicher 2016-01-08 08:13:28 UTC
Fixed by changeset:   294734:29cbc327d229
http://hg.netbeans.org/core-main/rev/29cbc327d229
There were several associated subtle problems, I've hopefully addressed all of them.

The main obstacle is caused by many other threads hitting breakpoints during stepping. Even when the whole VM is suspended and we do step in just one thread, newly created threads are waken up and they can hit breakpoints. This is a behavior of debugger backend.

I've tested the fix with your test case thoroughly and hopefully it behaves well now. I propose to include the fix into the 8.1 patch. Can you please verify it in trunk? Thanks.
Comment 3 Jiri Kovalsky 2016-01-08 09:06:23 UTC
Gili, if you help us verify Martin's fix in the next development build, there is a chance this bug fix could be included in the upcoming 8.1 update. Thanks for your cooperation!
Comment 4 Quality Engineering 2016-01-09 02:41:41 UTC
Integrated into 'main-silver', will be available in build *201601090002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/29cbc327d229
User: mentlicher@netbeans.org
Log: #257412: Solving various subtle inconsistenties that emerge especially when breakpoints suspend all threads.
Track which threads performing steps were suspended by what event threads and mark threads suspended on an event.
Comment 5 _ gtzabari 2016-01-13 10:14:53 UTC
Verified as fixed in Build 201601130002.

Thank you for the quick turnaround!
Comment 6 Martin Entlicher 2016-01-14 13:52:29 UTC
Thanks for the quick verification, I've transplanted the fix into release81 branch:
http://hg.netbeans.org/releases/rev/83f4307649d6
http://hg.netbeans.org/releases/rev/76b2449b9e24