JDK-6751643 : ThreadReference.ownedMonitors() can return null
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-09-23
  • Updated: 2012-02-02
  • 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.
JDK 6 JDK 7 Other
6u11Fixed 7 b38Fixed OpenJDK6Fixed
Related Reports
Relates :  
Description
So can ThreadReference.ownedMonitorsAndFrames().  In addition, ThreadReference.frames() can throw an NPE.

These problems are caused by the fix for 6700889.   They only occur if a resume is done on a thread in a small window of time while one of these commands is in progress in a different thread.

Comments
EVALUATION http://hg.openjdk.java.net/jdk6/jdk6/jdk/rev/dd7969318d7a
08-12-2009

SUGGESTED FIX Use a local reference for the cache in the affected methods. If a resume occurs and a new initialized cache object is created, it doesn't cause problems for simultaneously executing methods since they will continue working with the old cache object. See attached webrev.
03-10-2008

WORK AROUND This bug can only occur if a debugger has multiple threads and calls any of the following methods in one thread while simultaneously resuming the same debuggee thread in a different debugger thread. Debuggers shouldn't do this because it is a race condition and the result returned by these methods will vary depending upon just where in the processing of these methods the resume takes effect. EG, the frameCount() method could return 6 in a case where the debuggee has already been resumed and there are no frames. After this bug is fixed, the invalid return values shown below will no longer be returned and the related exceptions will not occur. Until this bug is fixed, JDI clients can use the following workarounds: - ownedMonitors() : Treat null as an empty list - ownedMontitorsAndFrames: Catch NullPointerExceptions and treat as a return value of an empty list - frameCount: Treat -1 as 0 - stackFrames: Catch NPE and treat as a return value of an empty list
24-09-2008

EVALUATION Data for the methods described in the description are cached in the JDI front-end while a thread is suspended, to avoid unnecessary JDWP calls that would fetch the identical data. The cache is reset when the debuggee thread is resumed. If this reset occurs at the right time during the execution of one of the specified methods, then the reset cache value is returned or used.
23-09-2008