JDK-6485605 : "com.sun.jdi.InternalException: Inconsistent suspend policy" in internal event handler
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-10-24
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
5.0u11Fixed 6u1Fixed 7 b03Fixed
Related Reports
Relates :  
Description
During test development I found case when internal event handler throws InternalException with description "Inconsistent suspend policy":
Exception in thread "JDI Internal Event Handler" com.sun.jdi.InternalException: Inconsistent suspend policy
	at com.sun.tools.jdi.EventSetImpl.resume(EventSetImpl.java:764)
	at com.sun.tools.jdi.EventSetImpl.build(EventSetImpl.java:635)
	at com.sun.tools.jdi.EventQueueImpl.removeUnfiltered(EventQueueImpl.java:193)
	at com.sun.tools.jdi.EventQueueImpl.removeInternal(EventQueueImpl.java:106)
	at com.sun.tools.jdi.InternalEventHandler.run(InternalEventHandler.java:36)
	at java.lang.Thread.run(Thread.java:619)

Test is attached.

Comments
SUGGESTED FIX See attached webrev.
01-11-2006

SUGGESTED FIX The fix is to remember the thread from events that are filtered out so it can be used to do a Thread.resume in the case where it is a SUSPEND_EVENT_THREAD type of EventSet.
26-10-2006

EVALUATION The problem is EventSetImpl.build. The code filters out Events for which no enabled request can be found. It then notices that the resulting EventSet is empty, and then calls EventSet.resume() to resume the debuggee. If it is a SUSPEND_ALL EventSet, this is fine. But if it is a SUSPEND_EVENT_TREAD EventSet, then resume() searches thru the EventSet to find an Event from which it can get the thread to be resumed. But, the EventSet is empty so resume() thows InternalException("Inconsistent suspend policy");
26-10-2006

EVALUATION This bug is related to: 6296125 JDI: Disabling an EventRequest can cause a multi-threaded debuggee to hang 6293795 Backend hangs when invokeMethod is called from a JDI eventHandler I think it is actually caused by the fix for 6293795 - at least the testcase doesn't fail before 5.0_10 which contains the fix for 6293795. I suspect that some problems could still occur in those earlier releases, but haven't looked for them. The problem only occurs when a debugger enables an EventRequest on a thread/threads that are already running, and it is a SUSPEND_THREAD request. In this case, there is a window in the JDI code where it has sent the JDWP enable-event command to the back-end, but has not yet gotten back the response from the back-end and completed setting up the EventRequest. If the running thread triggers the event inside this window, the event cannot be matched to the not-yet-completed EventRequest which causes the EventHandler in the JDI code to mis-behave and throw the exception shown.
24-10-2006