Bug 141061 - com.sun.jdi.InvalidStackFrameException: Thread has been resumed
com.sun.jdi.InvalidStackFrameException: Thread has been resumed
Status: RESOLVED FIXED
Product: debugger
Classification: Unclassified
Component: Java
6.x
All All
: P1 (vote)
: 7.2
Assigned To: Martin Entlicher
issues@debugger
http://statistics.netbeans.org/except...
: RANDOM, THREAD
: 141687 157042 157363 158508 158799 159245 160624 162338 162339 173524 177627 177892 210112 (view as bug list)
Depends on: 161270
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-21 19:49 UTC by Torbjorn Norbye
Modified: 2012-05-01 09:57 UTC (History)
39 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
stacktrace (1.10 KB, text/plain)
2009-04-11 10:05 UTC, franci
Details
stacktrace (2.35 KB, text/plain)
2010-05-14 14:49 UTC, Egor Ushakov
Details
stacktrace (1.74 KB, text/plain)
2011-02-08 19:33 UTC, Egor Ushakov
Details
stacktrace (2.64 KB, text/plain)
2011-08-11 05:01 UTC, David Konecny
Details
stacktrace (1.56 KB, text/plain)
2012-02-28 14:19 UTC, Jan Becicka
Details
stacktrace (2.83 KB, text/plain)
2012-03-06 13:47 UTC, Tomas Mysik
Details
stacktrace (1.57 KB, text/plain)
2012-03-07 11:11 UTC, Tomas Mysik
Details
stacktrace (2.98 KB, text/plain)
2012-03-13 10:56 UTC, Petr Jiricka
Details
stacktrace (1.80 KB, text/plain)
2012-03-14 14:20 UTC, J Bachorik
Details
stacktrace (2.26 KB, text/plain)
2012-03-14 14:35 UTC, J Bachorik
Details
stacktrace (3.01 KB, text/plain)
2012-04-02 09:53 UTC, J Bachorik
Details
stacktrace (1.62 KB, text/plain)
2012-04-26 09:32 UTC, Jiri Rechtacek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2008-07-21 19:49:14 UTC
I'm getting many frequent exceptions while debugging just while moving the caret around in the editor (attempts to do
balloon evaluation / tooltip evaluation I think).

This is on OSX. I'm seeing a lot of exceptions while trying to debug.


Build: NetBeans IDE Dev (Build 080721)
VM: Java HotSpot(TM) Client VM, 1.5.0_13-119, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_13-b05-237
OS: Mac OS X, 10.5.4, i386
User comments: Just single stepping
STACKTRACE: (first 10 lines)
com.sun.jdi.InvalidStackFrameException: Thread has been resumed
        at com.sun.tools.jdi.StackFrameImpl.validateStackFrame(StackFrameImpl.java:61)
        at com.sun.tools.jdi.StackFrameImpl.location(StackFrameImpl.java:70)
        at org.netbeans.modules.debugger.jpda.expr.EvaluatorVisitor.getIdentifierByName(EvaluatorVisitor.java:1172)
        at org.netbeans.modules.debugger.jpda.expr.EvaluatorVisitor.visitIdentifier(EvaluatorVisitor.java:1238)
        at org.netbeans.modules.debugger.jpda.expr.EvaluatorVisitor.visitIdentifier(EvaluatorVisitor.java:172)
        at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1689)
        at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:49)
        at org.netbeans.modules.debugger.jpda.projects.EditorContextImpl.parseExpression(EditorContextImpl.java:1465)
        at sun.reflect.GeneratedMethodAccessor268.invoke(GeneratedMethodAccessor268.java:0)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Comment 1 Martin Entlicher 2008-07-22 22:21:36 UTC
Hopefully this is also fixed in changeset:   91617:336b808f2fcf
The stack frames are refreshed when they become obsolete, thus invalid stack frame should not be given to the evaluation
process. Please verify.
http://hg.netbeans.org/main/rev/336b808f2fcf
Comment 2 Petr Cyhelsky 2008-07-27 21:34:20 UTC
*** Issue 141687 has been marked as a duplicate of this issue. ***
Comment 3 Exceptions Reporter 2009-01-22 14:42:27 UTC
Reopening - reproduced in NetBeans IDE Dev (Build 20090121074310)
http://statistics.netbeans.org/exceptions/detail.do?id=79656
Comment 4 Exceptions Reporter 2009-01-26 12:45:53 UTC
This issue has already 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=79656
Comment 5 Martin Entlicher 2009-02-09 16:06:34 UTC
*** Issue 157042 has been marked as a duplicate of this issue. ***
Comment 6 Martin Entlicher 2009-02-09 16:06:49 UTC
*** Issue 157363 has been marked as a duplicate of this issue. ***
Comment 7 Martin Entlicher 2009-02-09 16:19:18 UTC
It's hopefully finally fixed in changeset:   116739:bf9693a8a6c4
http://hg.netbeans.org/main/rev/bf9693a8a6c4
Comment 8 Quality Engineering 2009-02-18 10:51:16 UTC
Integrated into 'main-golden', will be available in build *200902180201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/bf9693a8a6c4
User: mentlicher@netbeans.org
Log: #141061 - Prevent from InvalidStackFrameException: Thread has been resumed thrown from Evaluator. Also, we attach the expression to the exception so that we can better identify the problems in the future.
Comment 9 Jan Pokorsky 2009-03-19 15:35:28 UTC
Still reproducible. See http://statistics.netbeans.org/analytics/detail.do?id=145132. There are 7 duplicates with build
number newer than 200902180201.
Comment 10 Martin Entlicher 2009-03-23 15:56:22 UTC
*** Issue 158508 has been marked as a duplicate of this issue. ***
Comment 11 Martin Entlicher 2009-03-23 15:57:11 UTC
*** Issue 159245 has been marked as a duplicate of this issue. ***
Comment 12 Martin Entlicher 2009-03-23 15:57:41 UTC
*** Issue 160624 has been marked as a duplicate of this issue. ***
Comment 13 Martin Entlicher 2009-03-23 16:00:51 UTC
It would be valuable to have some steps how to reproduce this. But I understand that since this is a random issue, 100%
reproducible steps may not exist.
Comment 14 Martin Entlicher 2009-04-10 08:47:05 UTC
*** Issue 162338 has been marked as a duplicate of this issue. ***
Comment 15 Martin Entlicher 2009-04-10 08:48:17 UTC
*** Issue 162339 has been marked as a duplicate of this issue. ***
Comment 16 franci 2009-04-11 10:05:14 UTC
Build: NetBeans IDE 6.5 (Build 200811100001)
VM: Java HotSpot(TM) Client VM, 11.0-b15, Java(TM) Platform, Standard Edition for Business, 1.6.0_10-b33
OS: SunOS, 5.11, x86

User Comments: 
debugging a java application.

Stacktrace: 
com.sun.jdi.InvalidStackFrameException: Thread has been resumed
        at com.sun.tools.jdi.StackFrameImpl.validateStackFrame(StackFrameImpl.java:62)
        at com.sun.tools.jdi.StackFrameImpl.location(StackFrameImpl.java:71)
        at org.netbeans.modules.debugger.jpda.expr.TreeEvaluator.indexOf(TreeEvaluator.java:150)
        at org.netbeans.modules.debugger.jpda.expr.TreeEvaluator.evaluate(TreeEvaluator.java:105)
        at org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.evaluateIn(JPDADebuggerImpl.java:770)
        at org.netbeans.modules.debugger.jpda.breakpoints.BreakpointImpl.evaluateConditionIn(BreakpointImpl.java:677)
Comment 17 franci 2009-04-11 10:05:25 UTC
Created attachment 79928 [details]
stacktrace
Comment 18 Exceptions Reporter 2009-06-30 15:18:30 UTC
This issue already has 53 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=79656
Comment 19 Exceptions Reporter 2009-06-30 15:19:37 UTC
This issue already has 53 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=79656
Comment 20 Martin Entlicher 2009-06-30 15:25:16 UTC
Very similar to issue #158750.
Comment 21 Martin Entlicher 2009-07-01 10:52:51 UTC
*** Issue 158799 has been marked as a duplicate of this issue. ***
Comment 22 Martin Entlicher 2009-07-08 12:58:49 UTC
This should have been actually fixed together with issue #158750 in changeset:   137391:b8f16f4a60fa
http://hg.netbeans.org/main/rev/b8f16f4a60fa
Comment 23 Marian Petras 2009-11-25 13:27:15 UTC
I got the exception several times during the last two days.

I guess it is caused by a rather long condition expression on one of the line breakpoints (see http://statistics.netbeans.org/analytics/exception.do?id=308603 for details). The conditional line breakpoint was set on the first line of constructor of class java.util.IdentityHashMap(int). I got the exception when I invoked action Team > Find Issues... in the remote instance (the one being debugged) of NetBeans.

Summary of the breakpoint's properties:
- conditional line breakpoint
- condition: (expectedMaxSize == 2) || (expectedMaxSize == 3) || (expectedMaxSize == 5) || (expectedMaxSize == 10) || (expectedMaxSize == 11) || (expectedMaxSize == 21) || (expectedMaxSize == 42) || (expectedMaxSize == 43) || (expectedMaxSize == 85) || (expectedMaxSize == 170) || (expectedMaxSize == 171) || (expectedMaxSize == 341) || (expectedMaxSize == 682) || (expectedMaxSize == 683) || (expectedMaxSize == 1365) || (expectedMaxSize == 2730) || (expectedMaxSize == 2731) || (expectedMaxSize == 5461) || (expectedMaxSize == 10922) || (expectedMaxSize == 10923) || (expectedMaxSize == 21845) || (expectedMaxSize == 43690) || (expectedMaxSize == 43691) || (expectedMaxSize == 87381) || (expectedMaxSize == 174762) || (expectedMaxSize == 174763) || (expectedMaxSize == 349525) || (expectedMaxSize == 699050) || (expectedMaxSize == 699051) || (expectedMaxSize == 1398101) || (expectedMaxSize == 2796202) || (expectedMaxSize == 2796203) || (expectedMaxSize == 5592405)
- set on line IdentityHashMap:203  (first line of constructor IdentityHashMap(int) in JDK 6u18 b05)
- suspend mode: No thread (continue)
- print text: expected max. size = {=expectedMaxSize}

Because the exception's properties are rather exceptional, I lower the priority to P3.
Comment 24 Martin Entlicher 2009-11-26 01:40:32 UTC
*** Bug 177627 has been marked as a duplicate of this bug. ***
Comment 25 Egor Ushakov 2010-05-14 14:49:37 UTC
Created attachment 99012 [details]
stacktrace
Comment 26 Martin Entlicher 2010-07-16 15:16:28 UTC
*** Bug 173524 has been marked as a duplicate of this bug. ***
Comment 27 Martin Entlicher 2010-07-16 15:17:04 UTC
*** Bug 177892 has been marked as a duplicate of this bug. ***
Comment 28 Martin Entlicher 2010-07-16 22:21:15 UTC
It should be finally fixed by changeset:   174465:ed9146168c0c
http://hg.netbeans.org/main/rev/ed9146168c0c
I've tested it on the long condition on the breakpoint in IdentityHashMap.
Comment 29 Quality Engineering 2010-07-18 03:09:04 UTC
Integrated into 'main-golden', will be available in build *201007180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ed9146168c0c
User: mentlicher@netbeans.org
Log: #141061, #188345 Refuse to perform code evaluation if the thread is not suspended.
Comment 30 Quality Engineering 2010-07-29 03:17:53 UTC
Integrated into 'main-golden', will be available in build *201007290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/dfccc159581f
User: mentlicher@netbeans.org
Log: #187533, #188732 Cache the thread stack depth and assure that stack frames are retrieved only for suspended threads (thus preventing from IncompatibleThreadStateException. Also suspendedNoFire is set to false when a thread is resumed. This should also prevent from bug #141061.
Comment 31 Vladimir Voskresensky 2010-10-21 15:47:24 UTC
http://statistics.netbeans.org/analytics/exception.do?id=431912
reproducing in dev
Comment 32 Martin Entlicher 2010-11-05 14:08:20 UTC
From the exception reports we can see that the exception occurs after Continue.
Therefore there's likely some missing synchronization when Continue resumes threads...
The exception seems to be non-destructive.
Comment 33 Martin Entlicher 2010-11-05 15:35:21 UTC
Unfortunately, even though I've tried hard, I could not reproduce this.
If you have some steps to reproduce, please provide them.
Since the exception should not break anything, moving to P4.
Comment 34 Egor Ushakov 2011-02-08 19:33:49 UTC
Created attachment 105747 [details]
stacktrace
Comment 35 David Konecny 2011-08-11 05:01:25 UTC
Created attachment 109917 [details]
stacktrace
Comment 36 Marian Mirilovic 2011-08-17 10:23:12 UTC
279 dups ... and still coming, even from Nb 7.0.1
Comment 37 Martin Entlicher 2011-08-17 13:38:38 UTC
Not explored yet what makes the thread resumed.
Any steps that will help us to reproduce this would help.
Comment 38 David Konecny 2011-08-24 22:24:03 UTC
(In reply to comment #37)
> Not explored yet what makes the thread resumed.
> Any steps that will help us to reproduce this would help.

I had a particular debugging scenario where it was fairly reproducible. Unfortunately I cannot remember it now. If I bump into it again I will let you know.
Comment 39 Martin Entlicher 2011-09-07 15:50:09 UTC
I've added some logging in changeset:   201155:1700174456fd
Also, I've found one place with a bad locking. I'm not sure if this has caused this problem or not, the problem is that the exception is just a symptom of some bad state, but it's not clear how we got to this bad state.
http://hg.netbeans.org/main/rev/1700174456fd

I'm resolving as fixed for now, if the problem reappears, please report it through the Exceptions Reporter. That should include the newly added logging. Also, the steps that you did before the exception was thrown are welcomed, some test case would be great.
Comment 40 Quality Engineering 2011-09-08 14:32:27 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/1700174456fd
User: mentlicher@netbeans.org
Log: #141061 Further debugging added to be able to better identify the InvalidStackFrameException problem. Also the locking is fixed in CallStackFrameImpl.
Comment 41 Jan Becicka 2012-02-28 14:19:40 UTC
Created attachment 116184 [details]
stacktrace
Comment 42 Tomas Mysik 2012-03-06 13:47:14 UTC
Created attachment 116394 [details]
stacktrace

debugging java file
Comment 43 Tomas Mysik 2012-03-07 11:11:15 UTC
Created attachment 116421 [details]
stacktrace

debugging java file
Comment 44 Quality Engineering 2012-03-09 11:06:08 UTC
Integrated into 'main-golden', will be available in build *201203090400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/c9fc6f78210f
User: mentlicher@netbeans.org
Log: #141061: Attach a more detailed message to InvalidStackFrameException.
Comment 45 Petr Jiricka 2012-03-13 10:56:15 UTC
Created attachment 116657 [details]
stacktrace

Debugging NetBeans codebase.
Comment 46 J Bachorik 2012-03-14 14:20:14 UTC
Created attachment 116725 [details]
stacktrace
Comment 47 J Bachorik 2012-03-14 14:35:15 UTC
Created attachment 116726 [details]
stacktrace
Comment 48 Martin Entlicher 2012-03-26 13:02:32 UTC
Again, this looks like some awkward behavior of JDI.
I've managed to get this exception on a regular basis after application of this patch:

diff -r d5621170a2d2 debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluationContext.java
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluationContext.java	Mon Mar 26 14:19:59 2012 +0200
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluationContext.java	Mon Mar 26 14:54:35 2012 +0200
@@ -154,6 +154,15 @@
 
     public StackFrame getFrame() {
         try {
+            ThreadReference tr;
+            tr = frame.thread();
+            // Test:
+            logger.config("Test thread state:       initial: "+JPDAThreadImpl.getThreadStateLog(tr));
+            frame.thread().suspend();
+            logger.config("Test thread state: after suspend: "+JPDAThreadImpl.getThreadStateLog(tr));
+            frame.thread();
+            frame.thread().resume();
+            logger.config("Test thread state:  after resume: "+JPDAThreadImpl.getThreadStateLog(tr));
             frame.thread();
         } catch (InvalidStackFrameException isex) {
             // Update the stack frame


This patch does absolutely NOTHING. It just suspends an already suspended thread and then resumes it to make it just supended with suspend count == 1 again.
Doing only this results in an invalidation of the stack frame. :-(

Now we have at least some indication about the nature of this "bug".
Comment 49 J Bachorik 2012-04-02 09:53:21 UTC
Created attachment 117642 [details]
stacktrace

hitting a breakpoint
Comment 50 Jiri Rechtacek 2012-04-26 09:32:26 UTC
Created attachment 118794 [details]
stacktrace

Point the cursor over a parameter to show its value while debugging a java source.
Comment 51 Martin Entlicher 2012-04-27 06:19:28 UTC
*** Bug 210112 has been marked as a duplicate of this bug. ***
Comment 52 Jan Becicka 2012-04-27 06:33:11 UTC
14 duplicates. 378 reports.
Comment 53 Martin Entlicher 2012-04-27 06:49:44 UTC
Yes, no wonder when JDI is so fragile.
I hope to have some solution soon. It will be risky, but something must be done.
Comment 54 Martin Entlicher 2012-04-27 12:16:41 UTC
It should be mostly fixed by changeset:   220450:e2109c2f87de
http://hg.netbeans.org/main/rev/e2109c2f87de

I've found it very problematic to really assure, that the stack frame does not get invalidated at any time. If the target thread, that we perform the evaluation in, gets suspended in the backend (that can happen at any time and can not be prevented from), the thread might get suspended twice and we need to call "resume" on it, to reduce the suspend count to 1. This unfortunately invalidates the stack frame. I've submitted issue #211841 for this problem. It needs to be explored, if it's solvable.
Comment 55 Quality Engineering 2012-05-01 09:57:04 UTC
Integrated into 'main-golden', will be available in build *201205010400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e2109c2f87de
User: mentlicher@netbeans.org
Log: #141061: Minimizing the chance that we work with invalid stack frames.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo