JDK-4921421 : JVMTI GC events don't allow to call raw monitor/memory management
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-09-11
  • Updated: 2004-01-27
  • Resolved: 2004-01-09
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
5.0 betaFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description

Name: egR10015			Date: 09/11/2003


--------------------------------------
 Test            : nsk/jvmti/GarbageCollectionStart/gcstart002
                 : nsk/jvmti/GarbageCollectionFinish/gcfinish001
 TestBase        : testbase_vm
 VM              : all
 Mode            : all
 Platform        : generic
 OS              : generic
 JDK             : 1.5.0-b18
--------------------------------------

The JVMTI events GarbageCollectionStart, GarbageCollectionFinish
do not allow to call the raw monitor functions and memory management
functions. It contradicts the spec saying:

| This event is sent while the world is still stopped, thus the event
| handler should not use JNI functions or JVMTI functions (except the
| raw monitor functions, Allocate or Deallocate). 


The mentioned tests call the following functions

CreateRawMonitor()
RawMonitorEnter()
RawMonitorExit()
DestroyRawMonitor()
Allocate()
Deallocate()

during processing an appropriate GC event, but all the functions fail
with the error JVMTI_ERROR_UNATTACHED_THREAD.

To reproduce the bug run

sh do_gcstart.sh $JAVA_HOME for the test 'gcstart002'

or

sh do_gcfinish.sh $JAVA_HOME for the test 'gcfinish001'

in

/net/jano.sfbay/export/disk20/GammaBase/Bugs/<this bug number>

where JAVA_HOME should point to jdk1.5

----------------- output on Solsparc with HS 1.5-b18: -------------------
$ sh do_gcstart.sh ~/hotspot/jdk1.5/solsparc
gcstart002.c:
share/JVMTITools.c:
share/agent_tools.c:
share/jni_tools.c:
share/jvmti_tools.c:
share/native_thread.c:
share/nsk_tools.c:
Compiling test classes...
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b18)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b18, mixed mode)
Executing the test ...
- gcstart002.c, 159: setting event callbacks ...
- gcstart002.c, 167: setting event callbacks done
enabling JVMTI events ...
- gcstart002.c, 174: enabling the events done

- gcstart002.c, 114: >>>> GarbageCollectionStart event #1 received
- gcstart002.c, 34: GarbageCollectionStart: creating a raw monitor ...
# ERROR: gcstart002.c, 36: NSK_CPP_STUB3(CreateRawMonitor, jvmti_env, "_lock",
&_lock)
#   jvmti error: code=115, name=JVMTI_ERROR_UNATTACHED_THREAD
# ERROR: gcstart002.c, 39: TEST FAILED: GarbageCollectionStart: unable to create
a raw monitor

- gcstart002.c, 84: GarbageCollectionStart: allocating memory ...
# ERROR: gcstart002.c, 86: NSK_CPP_STUB3(Allocate, jvmti_env, MEM_SIZE, &mem)
#   jvmti error: code=115, name=JVMTI_ERROR_UNATTACHED_THREAD
# ERROR: gcstart002.c, 89: TEST FAILED: GarbageCollectionStart: unable to
allocate memory

- gcstart002.c, 120: <<<<

...

- gcstart002.c, 114: >>>> GarbageCollectionStart event #97 received
- gcstart002.c, 34: GarbageCollectionStart: creating a raw monitor ...
# ERROR: gcstart002.c, 36: NSK_CPP_STUB3(CreateRawMonitor, jvmti_env, "_lock",
&_lock)
#   jvmti error: code=115, name=JVMTI_ERROR_UNATTACHED_THREAD
# ERROR: gcstart002.c, 39: TEST FAILED: GarbageCollectionStart: unable to create
a raw monitor

- gcstart002.c, 84: GarbageCollectionStart: allocating memory ...
# ERROR: gcstart002.c, 86: NSK_CPP_STUB3(Allocate, jvmti_env, MEM_SIZE, &mem)
#   jvmti error: code=115, name=JVMTI_ERROR_UNATTACHED_THREAD
# ERROR: gcstart002.c, 89: TEST FAILED: GarbageCollectionStart: unable to
allocate memory

- gcstart002.c, 120: <<<<

- gcstart002.c, 125: VMDeath event received
exit code = 97
-------------------------------------------------------------------------

The tests will be available in release 23 of the testbase_vm.
======================================================================

Name: egR10015			Date: 09/30/2003


The same issue concerns the JVMTI event ObjectFree. In particular, the
function GetPhase() returns JVMTI_ERROR_UNATTACHED_THREAD during callback.

This bug affects the following NSK test:

nsk/jvmti/ObjectFree/objfree002

which will be available in release 23 of the testbase_vm.

Here is fragment of test log:
---------------------------------------------------------------
- objfree002.c, 33: >>>> ObjectFree event received
# ERROR: objfree002.c, 37: NSK_CPP_STUB2(GetPhase, jvmti_env, &phase)
#   jvmti error: code=115, name=JVMTI_ERROR_UNATTACHED_THREAD
# ERROR: objfree002.c, 39: TEST FAILED: unable to obtain phase of the VM execution
- objfree002.c, 58: CHECK PASSED: ObjectFree event #1 received for the object previously tagged with 8
- objfree002.c, 60: <<<<
---------------------------------------------------------------

======================================================================

Name: egR10015			Date: 10/22/2003


The bug affects also the following NSK test:

nsk/jvmti/ObjectFree/objfree001

which fixed version will be available in release 24 of the testbase_vm.

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta INTEGRATED IN: tiger-beta VERIFIED IN: tiger-beta2
14-06-2004

EVALUATION In addition to the callbacks for the GC events we also need to resolve this issue for the heap iteration callbacks. Also thread-local functions should be possible from these callbacks. ###@###.### 2003-09-30 For b25 we have corrected the implementation so that the following may be called from the ObjectFree, GarbageCollectionStart, or GarbageCollectionFinish events or the heap iteration callbacks :- SetEnvironmentLocalStorage GetEnvironmentLocalStorage RawMonitorEnter RawMonitorExit RawMonitorWait RawMonitorNotify RawMonitorNotifyAll Allocate Deallocate Note that new nsk/jvmti/GarbageCollectionStart/gcstart002 and nsk/jvmti/GarbageCollectionFinish/gcfinish001 test also call CreateRawMonitor and DestroyRawMonitor - we probably need to clarify if these functions are included in the terms "raw monitor functions" as used in the current version of the spec. ###@###.### 2003-10-13 After discussion it is now clear that we should also allow CreateRawMonitor and DestroyRawMonitor to be called from the callbacks for these events. 4937789 covers various JVMTI spec updates that include the wording to clarify this in the spec. Thus for b25 the above list of functions can be used in the GC callbacks. Once 4937789 is approved we will update the implementation so that CreateRawMonitor and DestroyRawMonitor can also be used. ###@###.### 2003-10-15 4937789 has been addressed so CreateRawMonitor and Destroy RawMonitor can now be called from the callbacks. I will therefore marked this bug as fixed in tiger-beta. ###@###.### 2003-11-21 The fixes for this bug were putback at b25 and then "enabled" by the spec changes that went into b32. I'm thus marking this bug as integrated in b32 (as it's currently an orphan in the fixed state).
11-06-2004