JDK-6366931 : JAVA_CRW_DEMO: two bugs in demo\jvmti\java_crw_demo\src\java_crw_demo.c
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 6
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-12-23
  • Updated: 2011-02-16
  • Resolved: 2006-05-03
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
5.0u8 b01Fixed 6Fixed
Description
FULL PRODUCT VERSION :
1.6.0-rc-b64

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
All OS.

A DESCRIPTION OF THE PROBLEM :
the static void write_instruction(MethodImage *mi) C functions has two bugs :

at line 1428 :

         case JVM_OPC_goto:
                            new_opcode = JVM_OPC_jsr_w;
has to be replaced by
         case JVM_OPC_goto:
                            new_opcode = JVM_OPC_goto_w;

At line 1493 when writing the new goto offset :
                  writeU4(ci, new_delta); /* write new and wide delta */

must be replaced by
                   writeU4(ci, new_delta - 3); /* write new and wide delta */

since the correct new offset is now new_delta - 3 and not new_delta.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

One easy way to reproduce the bug is to modify the line 1282 (adjust_instruction function).

For example replace
		if ((new_delta < -32768) || (new_delta > 32767)) {
by

		if ((new_delta < -16) || (new_delta > 15)) {

to force call to widen() function.


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
See description<

Comments
SUGGESTED FIX ------- java_crw_demo.c ------- *** /tmp/sccs.inai8b Tue Jan 31 12:09:40 2006 --- java_crw_demo.c Tue Jan 31 12:09:33 2006 *************** *** 1409,1415 **** new_opcode = opc_jsr_w; break; case opc_goto: ! new_opcode = opc_jsr_w; break; default: CRW_FATAL(ci, "unexpected opcode"); --- 1409,1415 ---- new_opcode = opc_jsr_w; break; case opc_goto: ! new_opcode = opc_goto_w; break; default: CRW_FATAL(ci, "unexpected opcode"); *************** *** 1474,1480 **** writeU1(ci, new_opcode); /* write inverse branch */ writeU2(ci, 3 + 5); /* beyond if and goto_w */ writeU1(ci, opc_goto_w); /* add a goto_w */ ! writeU4(ci, new_delta); /* write new and wide delta */ } else { CRW_FATAL(ci, "Unexpected widening"); } --- 1474,1480 ---- writeU1(ci, new_opcode); /* write inverse branch */ writeU2(ci, 3 + 5); /* beyond if and goto_w */ writeU1(ci, opc_goto_w); /* add a goto_w */ ! writeU4(ci, new_delta-3); /* write new and wide delta */ } else { CRW_FATAL(ci, "Unexpected widening"); }
31-01-2006

EVALUATION Implemented suggested fixes in the description. Thanks!
27-01-2006