JDK-6540288 : IterateThroughHeap crash when primitive field callback enabled
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 7
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-03-29
  • Updated: 2010-04-03
  • Resolved: 2007-06-20
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
6u4Fixed 7Fixed hs10Fixed
Description
A profiler vendor reports a crash using IterateThroughHeap when the primtive field callback enabled.

The crash is hard to duplicate but the following has observed to crash on windows-i586 about 1 in 50 runs:

java -mx512m -agentlib:SmallAgent -jar $JDK_HOME/jfc/SwingSet2/SwingSet2.jar

The test creates an agent thread and invokes IterateOverHeap and IterateThroughHeap in a loop (with a 100ms pause between each iteration). When the crash occurs it typically happens when the counter is <20 which suggests the problem is that the heap iteration is encountering an object that is only partially initialized or an internal object.

Comments
EVALUATION Bad memory access problem in invoke_primitive_field_callback_for_instance_fields. Problematic code is shown below: jvalue* value = (jvalue*)addr; // invoke the callback jint res = (*cb)(JVMTI_HEAP_REFERENCE_FIELD, &reference_info, wrapper->klass_tag(), wrapper->obj_tag_p(), *value, <======= May access bad memory because it copies 8 bytes from location "addr" when it needs to copy less than 8 bytes for char, short int types. value_type,
18-05-2007

EVALUATION This bug is very hard to reproduce it. I tried it on a three different windows box and still not able to reproduce it. I am going to let this test run in a loop for a day. If we do not get a good crash dump then it is difficult find out the cause of the problem.
06-04-2007