JDK-8221437 : assert(java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) == m()) failed: Should not change after link resolution
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-03-26
  • Updated: 2020-01-14
  • Resolved: 2019-04-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.
JDK 11 JDK 12 JDK 13
11.0.4Fixed 12.0.2Fixed 13 b15Fixed
Related Reports
Relates :  
Description
During stress test development following assertion has been hit:
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/lmesnik/ws/ks-apps/open/src/hotspot/share/prims/methodHandles.cpp:320), pid=25850, tid=25978
#  assert(java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) == m()) failed: Should not change after link resolution
#
# JRE version: Java(TM) SE Runtime Environment (13.0) (fastdebug build 13-internal+0-2019-03-21-1917549.lmesnik.null)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 13-internal+0-2019-03-21-1917549.lmesnik.null, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x1279b0c]  MethodHandles::init_method_MemberName(Handle, CallInfo&)+0x24c
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/lmesnik/ws/bigapps/results/ks/core.25850)
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

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

Command Line: -XX:MaxRAMPercentage=50 -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError -Djava.net.preferIPv6Addresses=false -XX:+DisplayVMOutputToStderr -XX:+UsePerfData -Xlog:gc*,gc+heap=debug:gc.log:uptime,timemillis,level,tags -XX:+DisableExplicitGC -XX:+StartAttachListener -XX:NativeMemoryTracking=detail -XX:+FlightRecorder --add-exports=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xerces.internal.parsers=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED -Djava.io.tmpdir=/home/lmesnik/ws/bigapps/results/ks/java.io.tmpdir -Duser.home=/home/lmesnik/ws/bigapps/results/ks/user.home -agentpath:/home/lmesnik/ws/ks-apps/build/linux-x64/images/test/hotspot/jtreg/native/libJvmtiStressModule.so -Xverify:all -javaagent:redefineagent.jar applications.kitchensink.process.stress.Main /home/lmesnik/ws/bigapps/results/ks/kitchensink.final.properties

Host: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 8 cores, 15G, Ubuntu 18.04.2 LTS
Time: Thu Mar 21 17:12:07 2019 PDT elapsed time: 9 seconds (0d 0h 0m 9s)

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

Current thread (0x00007fd33c72d800):  JavaThread "SpecJbb2005StressModule" [_thread_in_vm, id=25978, stack(0x00007fd301292000,0x00007fd301393000)]

Stack: [0x00007fd301292000,0x00007fd301393000],  sp=0x00007fd30138e180,  free space=1008k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1279b0c]  MethodHandles::init_method_MemberName(Handle, CallInfo&)+0x24c
V  [libjvm.so+0xdccab2]  java_lang_StackFrameInfo::set_method_and_bci(Handle, methodHandle const&, int, Thread*)+0x122
V  [libjvm.so+0x151a3cc]  JavaFrameStream::fill_frame(int, objArrayHandle, methodHandle const&, Thread*)+0x77c
V  [libjvm.so+0x151f190]  StackWalk::fill_in_frames(long, BaseFrameStream&, int, int, objArrayHandle, int&, Thread*)+0x250
V  [libjvm.so+0x151fef0]  StackWalk::fetchNextBatch(Handle, long, long, int, int, objArrayHandle, Thread*)+0x190
V  [libjvm.so+0xf02ad7]  JVM_MoreStackWalk+0x197
j  java.lang.StackStreamFactory$AbstractStackWalker.fetchStackFrames(JJII[Ljava/lang/Object;)I+0 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.fetchStackFrames(I)I+35 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.getNextBatch()I+61 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.peekFrame()Ljava/lang/Class;+32 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.hasNext()Z+1 java.base@13-internal
j  java.lang.StackStreamFactory$StackFrameTraverser.tryAdvance(Ljava/util/function/Consumer;)Z+16 java.base@13-internal
j  java.util.stream.ReferencePipeline.forEachWithCancel(Ljava/util/Spliterator;Ljava/util/stream/Sink;)Z+13 java.base@13-internal
j  java.util.stream.AbstractPipeline.copyIntoWithCancel(Ljava/util/stream/Sink;Ljava/util/Spliterator;)Z+32 java.base@13-internal
j  java.util.stream.AbstractPipeline.copyInto(Ljava/util/stream/Sink;Ljava/util/Spliterator;)V+49 java.base@13-internal
j  java.util.stream.AbstractPipeline.wrapAndCopyInto(Ljava/util/stream/Sink;Ljava/util/Spliterator;)Ljava/util/stream/Sink;+13 java.base@13-internal
j  java.util.stream.FindOps$FindOp.evaluateSequential(Ljava/util/stream/PipelineHelper;Ljava/util/Spliterator;)Ljava/lang/Object;+14 java.base@13-internal
j  java.util.stream.AbstractPipeline.evaluate(Ljava/util/stream/TerminalOp;)Ljava/lang/Object;+88 java.base@13-internal
j  java.util.stream.ReferencePipeline.findFirst()Ljava/util/Optional;+5 java.base@13-internal
j  java.util.logging.LogRecord$CallerFinder.lambda$get$1(Ljava/util/stream/Stream;)Ljava/util/Optional;+7 java.logging@13-internal
j  java.util.logging.LogRecord$CallerFinder$$Lambda$193.apply(Ljava/lang/Object;)Ljava/lang/Object;+8 java.logging@13-internal
j  java.lang.StackStreamFactory$StackFrameTraverser.consumeFrames()Ljava/lang/Object;+25 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.doStackWalk(JIIII)Ljava/lang/Object;+78 java.base@13-internal
v  ~StubRoutines::call_stub
V  [libjvm.so+0xdc1a3a]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x6ea
V  [libjvm.so+0x15209d0]  StackWalk::fetchFirstBatch(BaseFrameStream&, Handle, long, int, int, int, objArrayHandle, Thread*)+0x860
V  [libjvm.so+0x152111c]  StackWalk::walk(Handle, long, int, int, int, objArrayHandle, Thread*)+0x57c
V  [libjvm.so+0xf02606]  JVM_CallStackWalk+0x1d6
j  java.lang.StackStreamFactory$AbstractStackWalker.callStackWalk(JIII[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.beginStackWalk()Ljava/lang/Object;+31 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.walk()Ljava/lang/Object;+8 java.base@13-internal
j  java.lang.StackWalker.walk(Ljava/util/function/Function;)Ljava/lang/Object;+10 java.base@13-internal
j  java.util.logging.LogRecord$CallerFinder.get()Ljava/util/Optional;+9 java.logging@13-internal
j  java.util.logging.LogRecord.inferCaller()V+12 java.logging@13-internal
j  java.util.logging.LogRecord.getSourceClassName()Ljava/lang/String;+8 java.logging@13-internal
j  java.util.logging.SimpleFormatter.format(Ljava/util/logging/LogRecord;)Ljava/lang/String;+12 java.logging@13-internal
j  spec.jbb.JBBLogFormatter.format(Ljava/util/logging/LogRecord;)Ljava/lang/String;+6
j  java.util.logging.StreamHandler.publish(Ljava/util/logging/LogRecord;)V+14 java.logging@13-internal
j  java.util.logging.Logger.log(Ljava/util/logging/LogRecord;)V+90 java.logging@13-internal
j  java.util.logging.Logger.doLog(Ljava/util/logging/LogRecord;)V+46 java.logging@13-internal
j  java.util.logging.Logger.log(Ljava/util/logging/Level;Ljava/lang/String;)V+21 java.logging@13-internal
j  java.util.logging.Logger.info(Ljava/lang/String;)V+5 java.logging@13-internal
j  spec.jbb.JBBmain.main([Ljava/lang/String;)V+1168
v  ~StubRoutines::call_stub
V  [libjvm.so+0xdc1a3a]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x6ea
V  [libjvm.so+0x146c005]  invoke(InstanceKlass*, methodHandle const&, Handle, bool, objArrayHandle, BasicType, objArrayHandle, bool, Thread*) [clone .constprop.122]+0xbd5
V  [libjvm.so+0x146d08a]  Reflection::invoke_method(oop, Handle, objArrayHandle, Thread*)+0x19a
V  [libjvm.so+0xf160a2]  JVM_InvokeMethod+0x212
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@13-internal
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100 java.base@13-internal
j  jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6 java.base@13-internal
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+59 java.base@13-internal
j  applications.kitchensink.process.stress.modules.SpecJbb2005StressModule.execute()V+68
j  applications.kitchensink.process.stress.modules.StressModule.run()V+109
v  ~StubRoutines::call_stub
V  [libjvm.so+0xdc1a3a]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x6ea
V  [libjvm.so+0xdbeaaf]  JavaCalls::call_virtual(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, Thread*)+0x33f
V  [libjvm.so+0xdbecca]  JavaCalls::call_virtual(JavaValue*, Handle, Klass*, Symbol*, Symbol*, Thread*)+0xca
V  [libjvm.so+0xeff591]  thread_entry(JavaThread*, Thread*)+0x91
V  [libjvm.so+0x162ca16]  JavaThread::thread_main_inner()+0x1b6
V  [libjvm.so+0x1632aa6]  Thread::call_run()+0xf6
V  [libjvm.so+0x135300d]  thread_native_entry(Thread*)+0x10d

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  java.lang.StackStreamFactory$AbstractStackWalker.fetchStackFrames(JJII[Ljava/lang/Object;)I+0 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.fetchStackFrames(I)I+35 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.getNextBatch()I+61 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.peekFrame()Ljava/lang/Class;+32 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.hasNext()Z+1 java.base@13-internal
j  java.lang.StackStreamFactory$StackFrameTraverser.tryAdvance(Ljava/util/function/Consumer;)Z+16 java.base@13-internal
j  java.util.stream.ReferencePipeline.forEachWithCancel(Ljava/util/Spliterator;Ljava/util/stream/Sink;)Z+13 java.base@13-internal
j  java.util.stream.AbstractPipeline.copyIntoWithCancel(Ljava/util/stream/Sink;Ljava/util/Spliterator;)Z+32 java.base@13-internal
j  java.util.stream.AbstractPipeline.copyInto(Ljava/util/stream/Sink;Ljava/util/Spliterator;)V+49 java.base@13-internal
j  java.util.stream.AbstractPipeline.wrapAndCopyInto(Ljava/util/stream/Sink;Ljava/util/Spliterator;)Ljava/util/stream/Sink;+13 java.base@13-internal
j  java.util.stream.FindOps$FindOp.evaluateSequential(Ljava/util/stream/PipelineHelper;Ljava/util/Spliterator;)Ljava/lang/Object;+14 java.base@13-internal
j  java.util.stream.AbstractPipeline.evaluate(Ljava/util/stream/TerminalOp;)Ljava/lang/Object;+88 java.base@13-internal
j  java.util.stream.ReferencePipeline.findFirst()Ljava/util/Optional;+5 java.base@13-internal
j  java.util.logging.LogRecord$CallerFinder.lambda$get$1(Ljava/util/stream/Stream;)Ljava/util/Optional;+7 java.logging@13-internal
j  java.util.logging.LogRecord$CallerFinder$$Lambda$193.apply(Ljava/lang/Object;)Ljava/lang/Object;+8 java.logging@13-internal
j  java.lang.StackStreamFactory$StackFrameTraverser.consumeFrames()Ljava/lang/Object;+25 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.doStackWalk(JIIII)Ljava/lang/Object;+78 java.base@13-internal
v  ~StubRoutines::call_stub
j  java.lang.StackStreamFactory$AbstractStackWalker.callStackWalk(JIII[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.beginStackWalk()Ljava/lang/Object;+31 java.base@13-internal
j  java.lang.StackStreamFactory$AbstractStackWalker.walk()Ljava/lang/Object;+8 java.base@13-internal
j  java.lang.StackWalker.walk(Ljava/util/function/Function;)Ljava/lang/Object;+10 java.base@13-internal
j  java.util.logging.LogRecord$CallerFinder.get()Ljava/util/Optional;+9 java.logging@13-internal
j  java.util.logging.LogRecord.inferCaller()V+12 java.logging@13-internal
j  java.util.logging.LogRecord.getSourceClassName()Ljava/lang/String;+8 java.logging@13-internal
j  java.util.logging.SimpleFormatter.format(Ljava/util/logging/LogRecord;)Ljava/lang/String;+12 java.logging@13-internal
j  spec.jbb.JBBLogFormatter.format(Ljava/util/logging/LogRecord;)Ljava/lang/String;+6
j  java.util.logging.StreamHandler.publish(Ljava/util/logging/LogRecord;)V+14 java.logging@13-internal
j  java.util.logging.Logger.log(Ljava/util/logging/LogRecord;)V+90 java.logging@13-internal
j  java.util.logging.Logger.doLog(Ljava/util/logging/LogRecord;)V+46 java.logging@13-internal
j  java.util.logging.Logger.log(Ljava/util/logging/Level;Ljava/lang/String;)V+21 java.logging@13-internal
j  java.util.logging.Logger.info(Ljava/lang/String;)V+5 java.logging@13-internal
j  spec.jbb.JBBmain.main([Ljava/lang/String;)V+1168
v  ~StubRoutines::call_stub
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@13-internal
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100 java.base@13-internal
j  jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6 java.base@13-internal
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+59 java.base@13-internal
j  applications.kitchensink.process.stress.modules.SpecJbb2005StressModule.execute()V+68
j  applications.kitchensink.process.stress.modules.StressModule.run()V+109
v  ~StubRoutines::call_stub

Comments
Fix Request (11u, 12u) Backporting this trivial change avoids false assert failure. Patch applies cleanly to 11u and 12u, passes tier1, and the targeted tests that used to reliably trigger the assert. Risk is low, as described above.
01-05-2019

[~shade] No, it's not caused by JDK-8210457 . It looks like it was there since JDK-8174749.
30-04-2019

It's definitely a false assert. We have a methodHandle result of resolution in the CallInfo and there could be safepoints that could cause the Callinfo method to be old if there's a redefinition when LinkResolver::resolve* => CallInfo.resolved_method() == m ... // take safepoint to install ResolvedMethodName oop into table. This code makes sure what's in the table is not an old method. result.set_resolved_method_name(CHECK_(empty)); oop mname2 = init_method_MemberName(mname, result); ... methodHandle m = info.resolved_method(); // get m from the CallInfo above ... Handle resolved_method = info.resolved_method_name(); assert(java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) == m(), "Should not change after link resolution"); m could be an old method here. This looks like it's broken in the 11u sources that I'm looking at and likely the 12u sources. What I really want to make sure here is that the Method* inside the ResolvedMethodName is not old and is a new version of m, but the backport of this patch should fix things.
30-04-2019

I see this reproduces reliably with 11u and 12u, and gets fixed by this patch, with the workload like this: $ git clone https://github.com/bertramn/classgraph-issue-341.git $ cd classgraph-issue-341 $ mvn clean verify -Pjdk-11,hamcrest-old More details at https://github.com/classgraph/classgraph/issues/341. I would request backports once we understand that relaxing that assert in 11u and 12u is safe, and does not hide some actual issue. I think it is false negative assert after JDK-8210457, [~coleenp]?
30-04-2019

[~coleenp], is this caused by JDK-8210457 fix? Trying to link this assert failure properly, and backport where the other fix was backported.
30-04-2019

Yes, I will fix it.
01-04-2019

This assert is too strict because we have replaced the method with redefinition. You could also rewrite it as this also: assert(java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) == m() || m->is_old() "Should not change after link resolution, unless redefined"); Rather than passing a flag. This seems like an infrequent failure. [~lkuskov] do you want to do the fix?
01-04-2019

The suggested fix would be to add "could_be_old" parameter static oop init_method_MemberName(Handle mname_h, CallInfo& info, bool could_be_old = false); to skip assertion when method is called from java_lang_StackFrameInfo::set_method_and_bci only.
26-03-2019

Test tries to retrasnfrom classes which methods are executed and fails with this asserition. It happend when MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) is called for method on stack which have been retransformed already. In this case the info contains old method while java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) returns new instance.
26-03-2019