Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8076110

VM crash when class is redefined with Instrumentation.redefineClasses

    Details

    • Subcomponent:
    • Resolved In Build:
      b72

      Backports

        Description

        # To suppress the following error report, specify this argument
        # after -XX: or in .hotspotrc: SuppressErrorAt=/constantPool.cpp:562
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # Internal Error (/HUDSON/workspace/9-2-build-linux-amd64/jdk9/2493/hotspot/src/share/vm/oops/constantPool.cpp:562), pid=1717, tid=139782905890560
        # assert(error != __null && message != __null) failed: checking
        #
        # JRE version: Java(TM) SE Runtime Environment (9.0-b59) (build 1.9.0-ea-fastdebug-b59)
        # Java VM: Java HotSpot(TM) 64-Bit Server VM (1.9.0-ea-fastdebug-b59 interpreted mode linux-amd64 compressed oops)

          Issue Links

            Activity

            Hide
            aeriksso Andreas Eriksson (Inactive) added a comment -
            Looks like a race between one thread reading a cached resolution error from the system dictionary, and the redefining thread that removes it on class redefinition.
            Show
            aeriksso Andreas Eriksson (Inactive) added a comment - Looks like a race between one thread reading a cached resolution error from the system dictionary, and the redefining thread that removes it on class redefinition.
            Hide
            aeriksso Andreas Eriksson (Inactive) added a comment -
            Example calls in order:

            Breakpoint 1, SystemDictionary::delete_resolution_error (pool=0x7fffdfa0b8a0) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2166
            2166 void SystemDictionary::delete_resolution_error(ConstantPool* pool) {
            Deleting REs for pool 0x7fffdfa0b8a0
            #0 SystemDictionary::delete_resolution_error (pool=0x7fffdfa0b8a0) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2166
            #1 0x00007ffff5a4942b in VM_RedefineClasses::redefine_single_class (this=0x7fffde8d51c0, the_jclass=0x7fffb8000aa8, scratch_class_oop=0x7c009f630, __the_thread__=0x7ffff00e3000) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp:4089
            ...
            [Switching to Thread 0x7fffde7d5700 (LWP 28361)]

            Breakpoint 6, SystemDictionary::find_resolution_error (pool=..., which=29, message=0x7fffde7d4020) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2172
            2172 Symbol** message) {
            Finding RE from pool 0x7fffdfa0b8a0
            #0 SystemDictionary::find_resolution_error (pool=..., which=29, message=0x7fffde7d4020) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2172
            #1 0x00007ffff5633ef8 in ConstantPool::throw_resolution_error (this_cp=..., which=29, __the_thread__=0x7ffff01b8800) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/oops/constantPool.cpp:561
            #2 0x00007ffff56324b4 in ConstantPool::klass_at_impl (this_cp=..., which=29, save_resolution_error=true, __the_thread__=0x7ffff01b8800) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/oops/constantPool.cpp:236
            Show
            aeriksso Andreas Eriksson (Inactive) added a comment - Example calls in order: Breakpoint 1, SystemDictionary::delete_resolution_error (pool=0x7fffdfa0b8a0) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2166 2166 void SystemDictionary::delete_resolution_error(ConstantPool* pool) { Deleting REs for pool 0x7fffdfa0b8a0 #0 SystemDictionary::delete_resolution_error (pool=0x7fffdfa0b8a0) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2166 #1 0x00007ffff5a4942b in VM_RedefineClasses::redefine_single_class (this=0x7fffde8d51c0, the_jclass=0x7fffb8000aa8, scratch_class_oop=0x7c009f630, __the_thread__=0x7ffff00e3000) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp:4089 ... [Switching to Thread 0x7fffde7d5700 (LWP 28361)] Breakpoint 6, SystemDictionary::find_resolution_error (pool=..., which=29, message=0x7fffde7d4020) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2172 2172 Symbol** message) { Finding RE from pool 0x7fffdfa0b8a0 #0 SystemDictionary::find_resolution_error (pool=..., which=29, message=0x7fffde7d4020) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/classfile/systemDictionary.cpp:2172 #1 0x00007ffff5633ef8 in ConstantPool::throw_resolution_error (this_cp=..., which=29, __the_thread__=0x7ffff01b8800) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/oops/constantPool.cpp:561 #2 0x00007ffff56324b4 in ConstantPool::klass_at_impl (this_cp=..., which=29, save_resolution_error=true, __the_thread__=0x7ffff01b8800) at /home/aeriksso/sources/jdk9-dev/hotspot/src/share/vm/oops/constantPool.cpp:236
            Hide
            aeriksso Andreas Eriksson (Inactive) added a comment -
            The crash happens when the redefine occurs while the redefined method is still running.
            This is because VM_RedefineClasses::redefine_single_class deletes the resolution errors at redefine time, but the running method might still need them.
            Looks like this can be fixed by moving the delete_resolution_error call to the ConstantPool::deallocate_contents instead, which ensures that the cached resolution_errors are removed only when no method uses the constant pool any more.
            Show
            aeriksso Andreas Eriksson (Inactive) added a comment - The crash happens when the redefine occurs while the redefined method is still running. This is because VM_RedefineClasses::redefine_single_class deletes the resolution errors at redefine time, but the running method might still need them. Looks like this can be fixed by moving the delete_resolution_error call to the ConstantPool::deallocate_contents instead, which ensures that the cached resolution_errors are removed only when no method uses the constant pool any more.
            Hide
            aeriksso Andreas Eriksson (Inactive) added a comment -
            ConstantPool::deallocate_contents can happen when we are not at safepoint, which means we would have to take the SystemDictionary lock every time a constant pool is deallocated, to remove potentially cached resolution errors.

            To avoid locks, instead do the deletion of resolution errors when the {add,purge}_previous_version functions has come to the conclusion that the constant pool / resolution errors are not needed since the java methods are not running any more.
            These functions will only be called during safepoint, either after a class redefinition or when unloading classes.
            Show
            aeriksso Andreas Eriksson (Inactive) added a comment - ConstantPool::deallocate_contents can happen when we are not at safepoint, which means we would have to take the SystemDictionary lock every time a constant pool is deallocated, to remove potentially cached resolution errors. To avoid locks, instead do the deletion of resolution errors when the {add,purge}_previous_version functions has come to the conclusion that the constant pool / resolution errors are not needed since the java methods are not running any more. These functions will only be called during safepoint, either after a class redefinition or when unloading classes.
            Show
            aeriksso Andreas Eriksson (Inactive) added a comment - Review thread: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2015-June/014948.html
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/031d1463ed4c
            User: mgronlun
            Date: 2015-06-16 16:42:28 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/031d1463ed4c User: mgronlun Date: 2015-06-16 16:42:28 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/031d1463ed4c
            User: lana
            Date: 2015-07-08 22:17:29 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/031d1463ed4c User: lana Date: 2015-07-08 22:17:29 +0000
            Hide
            mcastegr Mattis Castegren (Inactive) added a comment -
            Suggested release note:
            The JVM could crash when a class was redefined with Instrumentation.redefineClasses(). The crash could either be a segmentation fault at SystemDictionary::resolve_or_null, or an internal error with the message "tag mismatch with resolution error table". This has now been fixed
            Show
            mcastegr Mattis Castegren (Inactive) added a comment - Suggested release note: The JVM could crash when a class was redefined with Instrumentation.redefineClasses(). The crash could either be a segmentation fault at SystemDictionary::resolve_or_null, or an internal error with the message "tag mismatch with resolution error table". This has now been fixed

              People

              • Assignee:
                aeriksso Andreas Eriksson (Inactive)
                Reporter:
                shadowbug Shadow Bug
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: