JDK-8234645 : ARM32: C1: PatchingStub for field access: not enough bytes
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11.0.6,14
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: aarch32
  • Submitted: 2019-11-22
  • Updated: 2024-08-05
  • Resolved: 2019-11-28
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 13 JDK 14
11.0.6Fixed 13.0.5Fixed 14 b26Fixed
Related Reports
Relates :  
Description
While executing the jtreg test "compiler.c2.Test6877254" in a debug VM, the VM hits the following assert:

#  Internal Error (src/hotspot/share/c1/c1_CodeStubs.hpp:433), pid=14536, tid=14542
#  assert(_bytes_to_copy <= (masm->pc() - pc_start())) failed: not enough bytes

GDB shows the following backtrace:

#0  0x7624008e in PatchingStub::install (this=0x636132e8, masm=0x63612668, patch_code=lir_patch_low, obj=0x0, info=0x635edd00)
    at src/hotspot/share/c1/c1_CodeStubs.hpp:433
#1  0x7623d6a2 in LIR_Assembler::patching_epilog (this=0x640ae3e8, patch=0x636132e8, patch_code=lir_patch_low, obj=0x0, info=0x635edd00)
    at src/hotspot/share/c1/c1_LIRAssembler.cpp:44
#2  0x76243b0e in LIR_Assembler::mem2reg (this=0x640ae3e8, src=0x635edd80, dest=0x2810093, type=T_LONG, patch_code=lir_patch_normal, info=0x635edd00, wide=false, unaligned=false)
    at src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp:810
#3  0x7623f5a2 in LIR_Assembler::move_op (this=0x640ae3e8, src=0x635edd80, dest=0x2810093, type=T_LONG, patch_code=lir_patch_normal, info=0x635edd00, pop_fpu_stack=false, unaligned=false, wide=false)
    at src/hotspot/share/c1/c1_LIRAssembler.cpp:835
#4  0x7623e924 in LIR_Assembler::emit_op1 (this=0x640ae3e8, op=0x635edd98)
    at src/hotspot/share/c1/c1_LIRAssembler.cpp:514
#5  0x76237902 in LIR_Op1::emit_code (this=0x635edd98, masm=0x640ae3e8)
    at src/hotspot/share/c1/c1_LIR.cpp:1005
#6  0x7623e0e8 in LIR_Assembler::emit_lir_list (this=0x640ae3e8, list=0x635edb78)
    at src/hotspot/share/c1/c1_LIRAssembler.cpp:299
#7  0x7623df98 in LIR_Assembler::emit_block (this=0x640ae3e8, block=0x63883f18)
    at src/hotspot/share/c1/c1_LIRAssembler.cpp:264
#8  0x7623de3c in LIR_Assembler::emit_code (this=0x640ae3e8, hir=0x635ebf20)
    at src/hotspot/share/c1/c1_LIRAssembler.cpp:223
#9  0x762074c0 in Compilation::emit_code_body (this=0x640ae60c)
    at src/hotspot/share/c1/c1_Compilation.cpp:352
#10 0x762076d4 in Compilation::compile_java_method (this=0x640ae60c)
    at src/hotspot/share/c1/c1_Compilation.cpp:404
#11 0x76207932 in Compilation::compile_method (this=0x640ae60c)
    at src/hotspot/share/c1/c1_Compilation.cpp:460
#12 0x76207e48 in Compilation::Compilation (this=0x640ae60c, compiler=0x75feb9b8, env=0x640ae8d0, method=0x638f6860, osr_bci=-1, buffer_blob=0x73d8a448, directive=0x75fcfc00)
    at src/hotspot/share/c1/c1_Compilation.cpp:583
#13 0x7620b000 in Compiler::compile_method (this=0x75feb9b8, env=0x640ae8d0, method=0x638f6860, entry_bci=-1, directive=0x75fcfc00)
    at src/hotspot/share/c1/c1_Compiler.cpp:247
#14 0x7634119c in CompileBroker::invoke_compiler_on_method (task=0x6413f820)
    at src/hotspot/share/compiler/compileBroker.cpp:2115
#15 0x763404be in CompileBroker::compiler_thread_loop ()
    at src/hotspot/share/compiler/compileBroker.cpp:1800
#16 0x767f5c18 in compiler_thread_entry (thread=0x6413bc00, __the_thread__=0x6413bc00)
    at src/hotspot/share/runtime/thread.cpp:3445
#17 0x767f2030 in JavaThread::thread_main_inner (this=0x6413bc00)
    at src/hotspot/share/runtime/thread.cpp:1960
#18 0x767f1f10 in JavaThread::run (this=0x6413bc00)
    at src/hotspot/share/runtime/thread.cpp:1943
#19 0x767ef334 in Thread::call_run (this=0x6413bc00)
    at src/hotspot/share/runtime/thread.cpp:398
#20 0x766f34fa in thread_native_entry (thread=0x6413bc00)
    at src/hotspot/os/linux/os_linux.cpp:790
#21 0x76f82568 in start_thread () from /usr/lib/libpthread.so.0
#22 0x76ec9ac8 in ?? () from /usr/lib/libc.so.6

In a release VM, the same test crashes with a SIGSEGV (at least if the test is executed using the JTreg harness. Executing the tests manually does not result in a crash for me):

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x744d19bc, pid=14743, tid=14744
#
# JRE version: OpenJDK Runtime Environment (14.0) (build 14-internal+0-experimental-microdoc-internal-linux-armv7a-le-gcc494-gnueabihf)
# Java VM: OpenJDK Client VM (14-internal+0-experimental-microdoc-internal-linux-armv7a-le-gcc494-gnueabihf, compiled mode, serial gc, linux-arm)
# Problematic frame:
# J 859 c1 java.util.jar.JarFile.getManEntry()Ljava/util/jar/JarEntry; java.base@14-internal (93 bytes) @ 0x744d19bc [0x744d1900+0x000000bc]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e" (or dumping to /home/microdoc/cgo/jtreg_test_hotspot_jtreg_tier1/scratch/0/core.14743)
#
# An error report file with more information is saved as:
# /home/microdoc/cgo/jtreg_test_hotspot_jtreg_tier1/scratch/0/hs_err_pid14743.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

Comments
Fix Request [13u] Need to fix C1 patching. Applies cleanly, mentioned test fails without patch and passes after the fix. hotspot tier1 is also ok.
18-06-2020

Fix request The actual bug is old, but since JDK-8233081 was backported it really messes up C1's code patching. We need this fix to avoid severe issues. Fix is trivial and applies cleanly.
28-11-2019

URL: https://hg.openjdk.java.net/jdk/jdk/rev/643d9cf3d8fc User: mdoerr Date: 2019-11-28 11:06:29 +0000
28-11-2019

Yes, those are related. I tracked down the bug and it was introduced by that change. I think the problem is, that the "NativeMovRegMem" assumes that the length of every patch is 8 bytes. But accessing long fields, for instance, creates 2 patches, one of which is 4 bytes and the other is 8 bytes. See https://hg.openjdk.java.net/jdk/jdk/file/f16e4154dd7b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp#l808 and https://hg.openjdk.java.net/jdk/jdk/file/f16e4154dd7b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp#l848.
26-11-2019

Might be related to JDK-8233081. Martin, can you please have a look?
26-11-2019

I am not sure if the instruction size for NativeMovRegMem on ARM32 is wrong, or if the problem is somewhere else: https://hg.openjdk.java.net/jdk/jdk/file/f16e4154dd7b/src/hotspot/cpu/arm/nativeInst_arm_32.hpp#l353
22-11-2019