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

InterpreterRuntime::verify_mdp() missing lock while printing MethodData on failure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 24
    • hotspot
    • master

      When InterpreterRuntime::verify_mdp() fails (due to missing with profiling data), it tries to print the MethodData.

      Printing MethodData requires the extra_data_lock() to be held, so if the mdp verification fails, the VM crashes because the lock is not held.

      I.e. the crash is something like this:

      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (.../src/hotspot/share/oops/methodData.cpp:1898), pid=3645849, tid=3645852
      # assert(self->extra_data_lock()->owned_by_self()) failed: must have lock
      #
      # JRE version: OpenJDK Runtime Environment (24.0) (slowdebug build 24-internal-adhoc.tschatzl.jdk)
      # Java VM: OpenJDK 64-Bit Server VM (slowdebug 24-internal-adhoc.tschatzl.jdk, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
      # Problematic frame:
      # V [libjvm.so+0x138d86f] MethodData::check_extra_data_locked() const+0x59
      #
      # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to .../make/core.3645849)
      #
      # If you would like to submit a bug report, please visit:
      # https://bugreport.java.com/bugreport/crash.jsp
      #

      --------------- S U M M A R Y ------------

      Command Line: -Denv.class.path= -Dapplication.home=.../build/linux-x86_64-server-slowdebug/jdk -Xms8m -Djdk.module.main=jdk.jlink jdk.jlink/jdk.tools.jmod.Main create --module-version 24-internal --target-platform linux-amd64 --module-path .../build/linux-x86_64-server-slowdebug/images/jmods --libs .../build/linux-x86_64-server-slowdebug/support/modules_libs/java.desktop --config .../build/linux-x86_64-server-slowdebug/support/modules_conf/java.desktop --class-path .../build/linux-x86_64-server-slowdebug/jdk/modules/java.desktop --header-files .../build/linux-x86_64-server-slowdebug/support/modules_include/java.desktop --legal-notices .../build/linux-x86_64-server-slowdebug/support/modules_legal/common:.../build/linux-x86_64-server-slowdebug/support/modules_legal/java.desktop --exclude **{_the.*,_*.marker*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM} --compress zip-1 --date 2024-10-31T09:23:32Z .../build/linux-x86_64-server-slowdebug/support/images/jmods/java.desktop.jmod

      Host: gremio, Intel(R) Xeon(R) W-2295 CPU @ 3.00GHz, 36 cores, 62G, Ubuntu 24.04.1 LTS
      Time: Tue Nov 12 15:19:50 2024 CET elapsed time: 0.934695 seconds (0d 0h 0m 0s)

      --------------- T H R E A D ---------------

      Current thread (0x00007e3b0002dc10): JavaThread "main" [_thread_in_Java, id=3645852, stack(0x00007e3b08e20000,0x00007e3b08f20000) (1024K)]

      Stack: [0x00007e3b08e20000,0x00007e3b08f20000], sp=0x00007e3b08f1ad30, free space=1003k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x138d86f] MethodData::check_extra_data_locked() const+0x59 (methodData.cpp:1898)
      V [libjvm.so+0x99526a] MethodData::extra_data_base() const+0x1c (methodData.hpp:2418)
      V [libjvm.so+0x1387246] ProfileData::print_data_on_helper(MethodData const*) const+0x3c (methodData.cpp:96)
      V [libjvm.so+0x13874fc] ProfileData::print_data_on(outputStream*, MethodData const*) const+0x3c (methodData.cpp:126)
      V [libjvm.so+0x138c8ee] MethodData::print_data_on(outputStream*) const+0xd4 (methodData.cpp:1566)
      V [libjvm.so+0x138c74e] MethodData::print_on(outputStream*) const+0xe4 (methodData.cpp:1548)
      V [libjvm.so+0xec9e7e] InterpreterRuntime::verify_mdp(Method*, unsigned char*, unsigned char*)+0x26c (interpreterRuntime.cpp:1102)
      j jdk.internal.classfile.impl.SplitConstantPool.map()Ljdk/internal/classfile/impl/EntryMap;+31 java.base
      j jdk.internal.classfile.impl.SplitConstantPool.tryFindClassOrInterface(ILjava/lang/constant/ClassDesc;)Ljdk/internal/classfile/impl/AbstractPoolEntry$ClassEntryImpl;+1 java.base
      j jdk.internal.classfile.impl.SplitConstantPool.classEntryForClassOrInterface(Ljava/lang/constant/ClassDesc;)Ljdk/internal/classfile/impl/AbstractPoolEntry$ClassEntryImpl;+18 java.base
      j jdk.internal.classfile.impl.SplitConstantPool.classEntry(Ljava/lang/constant/ClassDesc;)Ljava/lang/classfile/constantpool/ClassEntry;+11 java.base
      j java.lang.invoke.InvokerBytecodeGenerator.<init>(Ljava/lang/invoke/LambdaForm;ILjava/lang/String;Ljava/lang/String;Ljava/lang/invoke/MethodType;)V+103 java.base
      j java.lang.invoke.InvokerBytecodeGenerator.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/invoke/LambdaForm;Ljava/lang/invoke/MethodType;)V+11 java.base
      j java.lang.invoke.InvokerBytecodeGenerator.<init>(Ljava/lang/String;Ljava/lang/invoke/LambdaForm;Ljava/lang/invoke/MethodType;)V+8 java.base
      j java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Ljava/lang/invoke/LambdaForm;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MemberName;+21 java.base
      j java.lang.invoke.LambdaForm.compileToBytecode()V+69 java.base
      j java.lang.invoke.DirectMethodHandle.makePreparedLambdaForm(Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/LambdaForm;+782 java.base
      j java.lang.invoke.DirectMethodHandle.preparedLambdaForm(Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/LambdaForm;+17 java.base
      j java.lang.invoke.DirectMethodHandle.preparedLambdaForm(Ljava/lang/invoke/MemberName;Z)Ljava/lang/invoke/LambdaForm;+159 java.base
      j java.lang.invoke.DirectMethodHandle.preparedLambdaForm(Ljava/lang/invoke/MemberName;)Ljava/lang/invoke/LambdaForm;+2 java.base
      j java.lang.invoke.DirectMethodHandle.make(BLjava/lang/Class;Ljava/lang/invoke/MemberName;Ljava/lang/Class;)Ljava/lang/invoke/DirectMethodHandle;+163 java.base
      j java.lang.invoke.DirectMethodHandle.make(Ljava/lang/Class;Ljava/lang/invoke/MemberName;)Ljava/lang/invoke/DirectMethodHandle;+17 java.base
      j java.lang.invoke.DirectMethodHandle.make(Ljava/lang/invoke/MemberName;)Ljava/lang/invoke/DirectMethodHandle;+21 java.base
      j java.lang.invoke.Invokers.basicInvoker()Ljava/lang/invoke/MethodHandle;+60 java.base
      j java.lang.invoke.LambdaForm$NamedFunction.<init>(Ljava/lang/invoke/MethodType;)V+42 java.base
      j java.lang.invoke.LambdaForm$Name.<init>(Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)V+6 java.base
      j java.lang.invoke.Invokers.callSiteForm(Ljava/lang/invoke/MethodType;Z)Ljava/lang/invoke/LambdaForm;+225 java.base
      j java.lang.invoke.Invokers.linkToTargetMethod(Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MemberName;+2 java.base
      j java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/invoke/MemberName;+104 java.base
      j java.lang.invoke.MethodHandleNatives.linkCallSite(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/invoke/MemberName;+45 java.base
      v ~StubRoutines::call_stub 0x00007e3af8417d01
      V [libjvm.so+0xedbd75] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x65b (javaCalls.cpp:421)
      V [libjvm.so+0x1448c90] os::os_exception_wrapper(void (*)(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*), JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x3a (os_linux.cpp:4972)
      V [libjvm.so+0xedb717] JavaCalls::call(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x41 (javaCalls.cpp:329)
      V [libjvm.so+0xedb001] JavaCalls::call_static(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x161 (javaCalls.cpp:256)
      V [libjvm.so+0x1743abd] SystemDictionary::invoke_bootstrap_method(BootstrapInfo&, JavaThread*)+0x343 (systemDictionary.cpp:2365)
      V [libjvm.so+0x123a2f6] LinkResolver::resolve_dynamic_call(CallInfo&, BootstrapInfo&, JavaThread*)+0x2c (linkResolver.cpp:1887)
      V [libjvm.so+0x123a1c8] LinkResolver::resolve_invokedynamic(CallInfo&, constantPoolHandle const&, int, JavaThread*)+0x12a (linkResolver.cpp:1859)
      V [libjvm.so+0x1239321] LinkResolver::resolve_invoke(CallInfo&, Handle, constantPoolHandle const&, int, Bytecodes::Code, JavaThread*)+0x15d (linkResolver.cpp:1703)
      V [libjvm.so+0xec93db] InterpreterRuntime::resolve_invokedynamic(JavaThread*)+0xf9 (interpreterRuntime.cpp:964)
      V [libjvm.so+0xec95bf] InterpreterRuntime::resolve_from_cache(JavaThread*, Bytecodes::Code)+0x13f (interpreterRuntime.cpp:992)
      j jdk.internal.module.SystemModuleFinders$1.find(Ljava/lang/String;)Ljava/util/Optional;+5 java.base
      j jdk.internal.module.ModuleBootstrap.boot2()Ljava/lang/ModuleLayer;+292 java.base
      j jdk.internal.module.ModuleBootstrap.boot()Ljava/lang/ModuleLayer;+64 java.base
      j java.lang.System.initPhase2(ZZ)I+0 java.base
      v ~StubRoutines::call_stub 0x00007e3af8417d01
      V [libjvm.so+0xedbd75] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x65b (javaCalls.cpp:421)
      V [libjvm.so+0x1448c90] os::os_exception_wrapper(void (*)(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*), JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x3a (os_linux.cpp:4972)
      V [libjvm.so+0xedb717] JavaCalls::call(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x41 (javaCalls.cpp:329)
      V [libjvm.so+0xedb001] JavaCalls::call_static(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x161 (javaCalls.cpp:256)
      V [libjvm.so+0x1798ec4] call_initPhase2(JavaThread*)+0x103 (threads.cpp:317)
      V [libjvm.so+0x179a0b3] Threads::create_vm(JavaVMInitArgs*, bool*)+0x967 (threads.cpp:745)
      V [libjvm.so+0xfec5ab] JNI_CreateJavaVM_inner(JavaVM_**, void**, void*)+0x9d (jni.cpp:3596)
      V [libjvm.so+0xfeca0f] JNI_CreateJavaVM+0x36 (jni.cpp:3687)
      C [libjli.so+0x9088] InitializeJVM+0x151 (java.c:1488)
      C [libjli.so+0x5988] JavaMain+0xec (java.c:488)
      C [libjli.so+0xcb6c] ThreadJavaMain+0x2b (java_md.c:633)

      Admittedly the crash only happens if you have a programming error in the first place, but the verification code probably shouldn't crash itself.

            coleenp Coleen Phillimore
            tschatzl Thomas Schatzl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: