JDK-8023465 : JSR292: assert: i2c adapter must return to an interpreter frame
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs25
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2013-08-21
  • Updated: 2019-09-13
  • Resolved: 2014-09-04
Related Reports
Relates :  
Relates :  
Description
#  Internal Error (/Users/vladimir/ws/hotspot-comp/src/cpu/x86/vm/macroAssembler_x86.cpp:1242), pid=54671, tid=6403
#  assert(false) failed: DEBUG MESSAGE: i2c adapter must return to an interpreter frame

I hit this assert when working on 8022595. It turned out that it reproduces reliably when compiled version for some MH.linkTo* intrinsics is absent. We eagerly compile generated intrinsics, but there's a window between method handle intrinsic creation (in SystemDictionary::find_method_handle_intrinsic) and it's compilation (CompileBroker::compile_method is non-blocking). And it heavily depends on the load on compiler.       

How to reproduce reliably:

- disable signature polymorphic MH intrinsic method compilation
diff -r 83a1dceb9504 src/share/vm/classfile/systemDictionary.cpp
--- a/src/share/vm/classfile/systemDictionary.cpp	Wed Aug 21 11:13:03 2013 +0400
+++ b/src/share/vm/classfile/systemDictionary.cpp	Wed Aug 21 14:53:11 2013 +0400
@@ -2260,9 +2260,6 @@
     spe = NULL;
     // Must create lots of stuff here, but outside of the SystemDictionary lock.
     m = Method::make_method_handle_intrinsic(iid, signature, CHECK_(empty));
-    CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier,
-                                  methodHandle(), CompileThreshold, "MH", CHECK_(empty));
-
     // Now grab the lock.  We might have to throw away the new method,
     // if a racing thread has managed to install one at the same time.
     {

- run any program which excercise JSR292 code, e.g:
  $ javac jdk/test/java/lang/invoke/6998541/Test6998541.java
  $ fastdebug/java -Xbatch -XX:CICompilerCount=1 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 Test6998541


Registers content for one of the observed crashes:

rip = 0x00000001051bc370

"Executing findpc"
0x00000001051bc370 is at code_begin+80 in an AdapterHandler
Adapter for signature: AHE@0x00007f8d1d823b20: 0xbb000000 i2c: 0x00000001051bc320 c2i: 0x00000001051bc438 c2iUV: 0x00000001051bc40b
0x00000001051bc370 is at code_begin+80 in 
[CodeBlob (0x00000001051bc290)]
Framesize: 0
BufferBlob (0x00000001051bc290) used for I2C/C2I adapters

rax = 0x000000010537f45c is at entry_point+220 in (nmethod*)0x000000010537f1d0
Compiled method (c1)    3380  347       1       java.lang.invoke.LambdaForm$DMH/1252169911::invokeStatic_LL_L (15 bytes)
 total in heap  [0x000000010537f1d0,0x000000010537f7e0] = 1552
 relocation     [0x000000010537f2f8,0x000000010537f370] = 120
 main code      [0x000000010537f380,0x000000010537f5e0] = 608
 stub code      [0x000000010537f5e0,0x000000010537f6c0] = 224
 oops           [0x000000010537f6c0,0x000000010537f6c8] = 8
 metadata       [0x000000010537f6c8,0x000000010537f6d8] = 16
 scopes data    [0x000000010537f6d8,0x000000010537f728] = 80
 scopes pcs     [0x000000010537f728,0x000000010537f7c8] = 160
 dependencies   [0x000000010537f7c8,0x000000010537f7d0] = 8
 nul chk table  [0x000000010537f7d0,0x000000010537f7e0] = 16

rbx = 0x0000000104d11e50 is pointing into metadata

rcx = 0x00000001051eaac0 is at begin+25 in a stub
MethodHandle::interpreter_entry::_linkToStatic [0x00000001051eaaa7, 0x00000001051eac82[ (475 bytes)
rdx = 0x00000001704b3740 is an oop
[Ljava.lang.Object; 
 - klass: 'java/lang/Object'[]
 - length: 1
 -   0 : a 'java/lang/Integer' = 0

rdi = 0x00000001701bb420 is an oop
java.lang.invoke.MemberName 
 - klass: 'java/lang/invoke/MemberName'
 - ---- fields (total size 7 words):
 - private 'flags' 'I' @12  100728840 (6010008)
 - private strict 'clazz' 'Ljava/lang/Class;' @32  a 'java/lang/Class' = 'java/lang/invoke/LambdaForm$NFI' (2e03766b 2e037163)
 - private 'name' 'Ljava/lang/String;' @36  "invoke_Z_Z" (2e037163 2dfdb246)
 - private 'type' 'Ljava/lang/Object;' @40  a 'java/lang/invoke/MethodType' = (Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object; (2dfdb246 0)
 - private 'resolution' 'Ljava/lang/Object;' @44  NULL (0 2e03766b)

rsi = 0x00000001700c1258 is an oop
java.lang.invoke.DirectMethodHandle 
 - klass: 'java/lang/invoke/DirectMethodHandle'
 - ---- fields (total size 3 words):
 - private final 'type' 'Ljava/lang/invoke/MethodType;' @12  a 'java/lang/invoke/MethodType' = (Z)Z (2e009b6f 2e009ceb)
 - final 'form' 'Ljava/lang/invoke/LambdaForm;' @16  a 'java/lang/invoke/LambdaForm' => a 'java/lang/invoke/MemberName' = {method}
 {0x0000000104d00640} 'invokeStatic_I_I' '(Ljava/lang/Object;I)I' in 'java/lang/invoke/LambdaForm$DMH' (2e009ceb 2e018244)
 - final 'member' 'Ljava/lang/invoke/MemberName;' @20  a 'java/lang/invoke/MemberName' = {method}
 {0x0000000104b661c0} 'identity' '(Z)Z' in 'sun/invoke/util/ValueConversions' (2e018244 1)
rbp = 0x00000001047ff1a0 is pointing into the stack for thread: 0x00007f8d1d800800
rsp = 0x00000001047ff188 is pointing into the stack for thread: 0x00007f8d1d800800
r8 = 0x0000000114581040 is pointing into metadata
r9 = 0x000000011458f940 is pointing into metadata
r10 = 0x000000002dfd5d0f is an unknown value
r11 = 0x00000001050f2e58 is an unknown value
r12 = 0x0000000000000000 is an unknown value
r13 = 0x00000001047ff1a0 is pointing into the stack for thread: 0x00007f8d1d800800
r14 = 0x00000001047ff198 is pointing into the stack for thread: 0x00007f8d1d800800
r15 = 0x00007f8d1d800800 is a thread
(rsp+0x000) 0x00000001047ff188: 0x000000010537f45c is at entry_point+220 in (nmethod*)0x000000010537f1d0
Compiled method (c1)    3382  347       1       java.lang.invoke.LambdaForm$DMH/1252169911::invokeStatic_LL_L (15 bytes)
 total in heap  [0x000000010537f1d0,0x000000010537f7e0] = 1552
 relocation     [0x000000010537f2f8,0x000000010537f370] = 120
 main code      [0x000000010537f380,0x000000010537f5e0] = 608
 stub code      [0x000000010537f5e0,0x000000010537f6c0] = 224
 oops           [0x000000010537f6c0,0x000000010537f6c8] = 8
 metadata       [0x000000010537f6c8,0x000000010537f6d8] = 16
 scopes data    [0x000000010537f6d8,0x000000010537f728] = 80
 scopes pcs     [0x000000010537f728,0x000000010537f7c8] = 160
 dependencies   [0x000000010537f7c8,0x000000010537f7d0] = 8
 nul chk table  [0x000000010537f7d0,0x000000010537f7e0] = 16
(rsp+0x008) 0x00000001047ff190: 0x00000001704b3740 is an oop
[Ljava.lang.Object; 
 - klass: 'java/lang/Object'[]
 - length: 1
 -   0 : a 'java/lang/Integer' = 0
(rsp+0x010) 0x00000001047ff198: 0x00000001700c1258 is an oop
java.lang.invoke.DirectMethodHandle 
 - klass: 'java/lang/invoke/DirectMethodHandle'
 - ---- fields (total size 3 words):
 - private final 'type' 'Ljava/lang/invoke/MethodType;' @12  a 'java/lang/invoke/MethodType' = (Z)Z (2e009b6f 2e009ceb)
 - final 'form' 'Ljava/lang/invoke/LambdaForm;' @16  a 'java/lang/invoke/LambdaForm' => a 'java/lang/invoke/MemberName' = {method}
 {0x0000000104d00640} 'invokeStatic_I_I' '(Ljava/lang/Object;I)I' in 'java/lang/invoke/LambdaForm$DMH' (2e009ceb 2e018244)
 - final 'member' 'Ljava/lang/invoke/MemberName;' @20  a 'java/lang/invoke/MemberName' = {method}
 {0x0000000104b661c0} 'identity' '(Z)Z' in 'sun/invoke/util/ValueConversions' (2e018244 1)
(rsp+0x018) 0x00000001047ff1a0: 0x0000000000000000 is an unknown value
(rsp+0x020) 0x00000001047ff1a8: 0x0000000104d14250 is pointing into metadata
(rsp+0x028) 0x00000001047ff1b0: 0x0000000000000000 is an unknown value
(rsp+0x030) 0x00000001047ff1b8: 0x00000001047ff1e0 is pointing into the stack for thread: 0x00007f8d1d800800
(rsp+0x038) 0x00000001047ff1c0: 0x00000001047ff1e0 is pointing into the stack for thread: 0x00007f8d1d800800
(rsp+0x040) 0x00000001047ff1c8:  0x000000010537f45c 0x00000001704b3628 0x00000001700ba4c8 0x00000001047ff1f0
(rsp+0x060) 0x00000001047ff1e8:  0x000000010537d314 0x00007f8d1d800800 0x00007f8d1cb257c8 0x00000001047ff220
(rsp+0x080) 0x00000001047ff208:  0x0000000103e0504d 0x0000000000000003 0x0000000000000003 0x00000001047ff230
(rsp+0x0a0) 0x00000001047ff228:  0x000000010537d314 0x0000000000000000 0x00007f8d1d800800 0x00000001047ff4b0
(rsp+0x0c0) 0x00000001047ff248:  0x0000000105379e14 0x0000000000000000 0x00000001047ff348 0x00000001047ff2a8
(rsp+0x0e0) 0x00000001047ff268:  0x0000000104d18250 0x00007f8d1d800800 0x00007f8d1d800800 0x00000001047ff460
(rsp+0x100) 0x00000001047ff288:  0x0000000105379e14 0x00007f8d1d800800 0x0000000000000001 0x00000001700c6120
(rsp+0x120) 0x00000001047ff2a8:  0x00000001704b3740 0x00000001704b3740 0x00007f8d1d800800 0x00000001047ff4b0
(rsp+0x140) 0x00000001047ff2c8:  0x000000010537be34 0x00000001047ff320 0x0000000103b01931 0x00000001700c9d90
(rsp+0x160) 0x00000001047ff2e8:  0x00000001704b3628 0x00000001704b3628 0x000000011458fde0 0x00000001704b3708
(rsp+0x180) 0x00000001047ff308:  0x00000001700c6108 0x00000001700c6150 0x00000001704b35c0 0x00000001047ff4b0
(rsp+0x1a0) 0x00000001047ff328:  0x000000010538014c 0x0000000000000002 0x0000000000000003 0x00000001704b35d8
(rsp+0x1c0) 0x00000001047ff348:  0x00000001700c9d78 0x00000001700c9dc0 0x0000000000000002 0x00000001047ff460
(rsp+0x1e0) 0x00000001047ff368:  0x000000002e0966c8 0x00000001047ff3b0 0x00000001043fae10 0x00000001700c6150
(rsp+0x200) 0x00000001047ff388:  0x00000001704b36f0 0x0000000100000003 0x00000001704b3708 0x0000000000000002
(rsp+0x220) 0x00000001047ff3a8:  0x0000000000000002 0x00000001047ff4b0 0x000000010539e44c 0x0000000104cf5bc0
(rsp+0x240) 0x00000001047ff3c8:  0x00000001047ff408 0x0000000104cf6550 0x0000000000000000 0x0000000104cf5bd0
(rsp+0x260) 0x00000001047ff3e8:  0x00000001043fae10 0x00000001047ff410 0x00000001047ff410 0x0000000105389e54
(rsp+0x280) 0x00000001047ff408:  0x0000000100000010 0x00000001050f42f7 0x00000001704b3640 0x00000001047ff420
(rsp+0x2a0) 0x00000001047ff428:  0x0000000104d0668a 0x00000001047ff478 0x0000000104d06730 0x00000001047ff4b0
(rsp+0x2c0) 0x00000001047ff448:  0x00000001050f4414 0x00000001043fae10 0x00000001050f4414 0x0000000000000010
(rsp+0x2e0) 0x00000001047ff468:  0x00000001700c61a0 0x00000001047ff470 0x0000000104d1c62b 0x00000001047ff4c8
(rsp+0x300) 0x00000001047ff488:  0x0000000104d1c6e0 0x0000000000000000 0x0000000104d1c650 0x00000001047ff460
(rsp+0x320) 0x00000001047ff4a8:  0x00000001047ff4d0 0x00000001047ff4d0 0x000000010537f45c 0x00000001704b36d8
(rsp+0x340) 0x00000001047ff4c8:  0x00000001700c61a0 0x00000001704b35a8 0x00000001700c9e10 0x00000001047ff600
Loaded disassembler from hsdis-amd64.dylib
[Disassembling for mach='i386:x86-64']
  0x00000001051bc330: retq   
  0x00000001051bc331: jbe    0x00000001051bc34a
  0x00000001051bc337: movabs $0x1051bb3e0,%r11
  0x00000001051bc341: cmp    %r11,%rax
  0x00000001051bc344: jb     0x00000001051bc3e7
  0x00000001051bc34a: movabs $0x1050ee420,%r11
  0x00000001051bc354: cmp    %r11,%rax
  0x00000001051bc357: jbe    0x00000001051bc370
  0x00000001051bc35d: movabs $0x1050f2e58,%r11
  0x00000001051bc367: cmp    %r11,%rax
  0x00000001051bc36a: jb     0x00000001051bc3e7
--------
  ;; i2c adapter must return to an interpreter frame
  0x00000001051bc370: mov    %rsp,-0x28(%rsp)
  0x00000001051bc375: sub    $0x80,%rsp
  0x00000001051bc37c: mov    %rax,0x78(%rsp)
  0x00000001051bc381: mov    %rcx,0x70(%rsp)
  0x00000001051bc386: mov    %rdx,0x68(%rsp)
  0x00000001051bc38b: mov    %rbx,0x60(%rsp)

Comments
This particular issue is not really a bug. MH intrinsics cannot be called from compiled code in any other way except by calling their compiled form. Calling interpreter entry points of MH intrinsics will potentially cause c2i -> i2c composition that will mess the frame. I'll put more detailed asserts in the fix for JDK-8056154.
04-09-2014

Workaround: -XX:-VerifyAdapterCalls It is only needed in a debug jvm; it is disabled by default in non-debug builds. (Thanks to Vladimir Kozlov.)
28-08-2014

RULE sun/management/jmxremote/bootstrap/LocalManagementTest.java Crash Internal Error ...macroAssembler_sparc.cpp...assert(false) failed: DEBUG MESSAGE: i2c adapter must return to an interpreter frame
27-05-2014

ILW=Assert; reproducible, none=MMH=P3
25-04-2014

This might be a duplicate of 8024008. However, 8024008 does not fix the problem - it just makes it less likely.
21-11-2013