JDK-8009531 : Crash when redefining class with annotated method
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-03-06
  • Updated: 2013-07-02
  • Resolved: 2013-03-27
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 8 Other
8Fixed hs25Fixed
Related Reports
Relates :  
Relates :  
Description
I get a crash when redefining a class and adding some basic instrumentation. Running with a debug build I see that the problem is when trying to get the length of the method annotations:

#0  0x00007ffff6ccdc66 in Array<unsigned char>::length (this=0x0) at main/src/share/vm/utilities/array.hpp:342
#1  0x00007ffff7312604 in ConstMethod::method_annotations_length (this=0x7ffff4465bc0)
    at main/src/share/vm/oops/constMethod.hpp:431
#2  0x00007ffff730f47f in Method::clone_with_new_data (m=..., new_code=0x7ffff01ed0e8 "\023\001\224\023\003e\270\003_\262\002\277\231",
    new_code_length=112, new_compressed_linenumber_table=0x7ffff01ed238 "\377", new_compressed_linenumber_size=15, __the_thread__=0x7ffff000e000)
    at main/src/share/vm/oops/method.cpp:1086
#3  0x00007ffff740a060 in Relocator::insert_space_at (this=0x7ffff7fd4ad0, bci=25, size=3, inst_buffer=0x7ffff7fd4c10 "\023\001\214\367,",
    __the_thread__=0x7ffff000e000) at main/src/share/vm/runtime/relocator.cpp:163
#4  0x00007ffff721f200 in VM_RedefineClasses::rewrite_cp_refs_in_method (this=0x7ffff7fd5370, method=..., new_method_p=0x7ffff7fd4c70,
    __the_thread__=0x7ffff000e000) at main/src/share/vm/prims/jvmtiRedefineClasses.cpp:1503
#5  0x00007ffff721ed1f in VM_RedefineClasses::rewrite_cp_refs_in_methods (this=0x7ffff7fd5370, scratch_class=..., __the_thread__=0x7ffff000e000)
    at main/src/share/vm/prims/jvmtiRedefineClasses.cpp:1419
#6  0x00007ffff721eb75 in VM_RedefineClasses::rewrite_cp_refs (this=0x7ffff7fd5370, scratch_class=..., __the_thread__=0x7ffff000e000)
    at main/src/share/vm/prims/jvmtiRedefineClasses.cpp:1363
#7  0x00007ffff721ea5b in VM_RedefineClasses::merge_cp_and_rewrite (this=0x7ffff7fd5370, the_class=..., scratch_class=..., __the_thread__=0x7ffff000e000)
    at main/src/share/vm/prims/jvmtiRedefineClasses.cpp:1340
#8  0x00007ffff721d50d in VM_RedefineClasses::load_new_class_versions (this=0x7ffff7fd5370, __the_thread__=0x7ffff000e000)
    at main/src/share/vm/prims/jvmtiRedefineClasses.cpp:943
#9  0x00007ffff721a7f7 in VM_RedefineClasses::doit_prologue (this=0x7ffff7fd5370)
    at main/src/share/vm/prims/jvmtiRedefineClasses.cpp:98
#10 0x00007ffff754d56b in VMThread::execute (op=0x7ffff7fd5370) at main/src/share/vm/runtime/vmThread.cpp:580
#11 0x00007ffff71f7022 in JvmtiEnv::RetransformClasses (this=0x7ffff0005a88, class_count=1, classes=0x7ffff025acb8)
    at main/src/share/vm/prims/jvmtiEnv.cpp:280
#12 0x00007ffff71b441c in jvmti_RetransformClasses (env=0x7ffff0005a90, class_count=1, classes=0x7ffff025acb8)
    at ../generated/jvmtifiles/jvmtiEnter.cpp:3829
#13 0x00007ffff5612020 in retransformClasses () from jdk1.8.0-b65/jre/lib/amd64/libinstrument.so
#14 0x00007fffed02378d in ?? ()

Meaning the has_method_annotations flag has been set, but the method_annotations are not (yet) set.
Comments
Fix verified: $ /localhome/java/jdk-8-ea-b84-2013-04-04/bin/java -version java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b84) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b25, mixed mode) $ jtreg -v1 -jdk /localhome/java/jdk-8-ea-b84-2013-04-04 jdk/test/java/lang/instrument/RedefineMethodWithAnnotations.sh FAILED: java/lang/instrument/RedefineMethodWithAnnotations.sh Test results: failed: 1 Report written to JTreport/html/report.html Results written to /localhome/ws/jdk8-tl/run/JTwork Error: Some tests failed or other problems occurred. $ grep -A10 SIGSEGV JTwork/java/lang/instrument/RedefineMethodWithAnnotations.jtr # SIGSEGV (0xb) at pc=0x00007f967aa4c939, pid=26482, tid=140284298987264 # # JRE version: Java(TM) SE Runtime Environment (8.0-b84) (build 1.8.0-ea-b84) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b25 mixed mode linux-amd64 compressed oops) # Problematic frame: # V [libjvm.so+0x7a8939] Method::clone_with_new_data(methodHandle, unsigned char*, int, unsigned char*, int, Thread*)+0xa9 # # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # # An error report file with more information is saved as: # /localhome/ws/jdk8-tl/run/JTwork/scratch/hs_err_pid26482.log $ /localhome/java/jdk-8-ea-b85-2013-04-11/bin/java -version java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b85) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b26, mixed mode) $ jtreg -v1 -jdk /localhome/java/jdk-8-ea-b85-2013-04-11 jdk/test/java/lang/instrument/RedefineMethodWithAnnotations.sh Passed: java/lang/instrument/RedefineMethodWithAnnotations.sh Test results: passed: 1 Report written to JTreport/html/report.html Results written to /localhome/ws/jdk8-tl/run/JTwork
30-04-2013

Forgot to copy the annotations to the new ConstMethod in clone_with_new_data.
26-03-2013

Mikael, please add your reproducer to the bug :)
07-03-2013

Assigning to you since this appears to be related to your method annotation changes.
06-03-2013

I have a reproducer available on demand.
06-03-2013

I did a quick search an noticed that this stopped working when the changes for "8007320: NPG: move method annotations" were integrated.
06-03-2013