JDK-6436034 : Instance filter doesn't filter event if it occurs in native method
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: hs20,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-06-08
  • Updated: 2011-04-19
  • Resolved: 2011-04-19
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 7
7 b128Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Several jdi event requests provide method addInstanceFilter(ObjectReference instance) which should restrict the events generated by this request to those in which the currently executing instance ("this") is the object specified. But if events occur in native method this filter doesn't affect such events.

Attached test try use instance filter for ExceptionRequest, MonitorContendedEnterRequest, MonitorContendedEnteredRequest. 10 objects in debuggee VM generate events in native method, debugger expect events only from one of them, but receive events generated by all objects.

Test output:

Breakpoint
Initialize requests
Requests initialized
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veThrowException()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Received event: ###@###.###veMonitorEnter()+-1 in thread main
Breakpoint
Received event: VMDeathEvent
Received event: VMDisconnectEvent

Total events:
Enter events: 10
Entered events: 10
Exception events: 10

Error: enter events != 1 actually: 10
Error: entered events != 1 actually: 10
Error: exception events != 1 actually: 10
TEST FAIL

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/tl/jdk/rev/f5c0b3cbee2f
13-01-2011

EVALUATION The evaluation of this bug points the blame at GetLocalObject not being able to query slot 0 of a native method to get the value of "this". It returns an error JVMTI_ERROR_OPAQUE_FRAME if it is a native frame. I think this is correct -- it matches the spec. Should one be able to get the value of arguments for a native? The spec defines that the mapping of slots is given by GetLocalVariableTable (and there is no such thing for native methods): http://java.sun.com/javase/6/docs/guide/jvmti/jvmti.html#local The JDWP agent has coding errors as it assumes an instance filter matches when the "this" value is null, and this occurs when the method is static (all static methods will pass the filter) and on error (as in this case). JPDA however should have some means of implementing this functionality. I think this means adding a GetThisObject function to JVM TI. I don't believe, at this late stage, that this is justified to do in Mustang.
20-06-2006

EVALUATION Here is a jtreg test for this: /net/jano.sfbay/export/disk20/serviceability/ws/regressionTestsInWaiting/InstanceFilterNative.java The problem is that the back-end event handler calls JVMTI GetLocalObject for slot 0 of the frame of the thread of the event to get 'this'. If the method of the event is native, this call returns 0 so the filtering by instance fails. JVMTI GetLocalObject should return a correct 'this' in this case, or the JVMTI (and JDWP and JDI) specs should be changed.
09-06-2006