Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jdk24 OpenJDK java/foreign/TestLinker crash vmState=0x00000000 #21017

Closed
pshipton opened this issue Jan 25, 2025 · 5 comments · Fixed by #21115 or adoptium/aqa-tests#5974
Closed

jdk24 OpenJDK java/foreign/TestLinker crash vmState=0x00000000 #21017

pshipton opened this issue Jan 25, 2025 · 5 comments · Fixed by #21115 or adoptium/aqa-tests#5974
Labels
comp:vm jdk24 segfault Issues that describe segfaults / JVM crashes test failure

Comments

@pshipton
Copy link
Member

Likely all platforms, I didn't check them all.
https://openj9-jenkins.osuosl.org/job/Test_openjdk24_j9_sanity.openjdk_x86-64_linux_Nightly_testList_0/2
java/foreign/TestLinker.java

04:31:05  Type=Segmentation error vmState=0x00000000
04:31:05  J9Generic_Signal_Number=00000018 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001
04:31:05  Handler1=00007FC5ADD80DF0 Handler2=00007FC5AF34E3C0 InaccessibleAddress=0000000000000003
04:31:05  RDI=0000000000552BA8 RSI=00007FC565B9600F RAX=0000000000000000 RBX=00000000003AD600
04:31:05  RCX=0000000000000006 RDX=0000000000000020 R8=0000000000000001 R9=00000000005527F8
04:31:05  R10=0000000000552748 R11=0000000000000002 R12=000000000056F778 R13=000000001C0C0100
04:31:05  R14=00007FC5ADF8F760 R15=0000000000000000
04:31:05  RIP=00007FC5ADDC7A59 GS=0000 FS=0000 RSP=00007FC5971158C0
04:31:05  EFlags=0000000000010216 CS=0033 RBP=00000000003AD300 ERR=0000000000000004
04:31:05  TRAPNO=000000000000000E OLDMASK=0000000000000000 CR2=0000000000000003
04:31:05  xmm0=0000000000000000 (f: 0.000000, d: 0.000000e+00)
04:31:05  xmm1=0000000000552720 (f: 5580576.000000, d: 2.757171e-317)
04:31:05  xmm2=00007fc5adf5bd70 (f: 2918563072.000000, d: 6.940980e-310)
04:31:05  xmm3=ffffffffffffffff (f: 4294967296.000000, d: -nan)
04:31:05  xmm4=00007fc5adf38540 (f: 2918417664.000000, d: 6.940980e-310)
04:31:05  xmm5=0000003000000020 (f: 32.000000, d: 1.018558e-312)
04:31:05  xmm6=00007fc5141f0580 (f: 337577344.000000, d: 6.940853e-310)
04:31:05  xmm7=00000000ffd00528 (f: 4291822848.000000, d: 2.120442e-314)
04:31:05  xmm8=000000000000000a (f: 10.000000, d: 4.940656e-323)
04:31:05  xmm9=0000000040400000 (f: 1077936128.000000, d: 5.325712e-315)
04:31:05  xmm10=000000003e8c05e2 (f: 1049363968.000000, d: 5.184547e-315)
04:31:05  xmm11=000000003c075284 (f: 1007112832.000000, d: 4.975799e-315)
04:31:05  xmm12=0000000040400000 (f: 1077936128.000000, d: 5.325712e-315)
04:31:05  xmm13=000001380000013f (f: 319.000000, d: 6.620627e-312)
04:31:05  xmm14=0000000008001800 (f: 134223872.000000, d: 6.631540e-316)
04:31:05  xmm15=000001420000013b (f: 315.000000, d: 6.832826e-312)
04:31:05  Module=/home/jenkins/workspace/Test_openjdk24_j9_sanity.openjdk_x86-64_linux_Nightly_testList_0/jdkbinary/j2sdk-image/lib/default/libj9vm29.so
04:31:05  Module_base_address=00007FC5ADD40000
04:31:05  Target=2_90_20250125_2 (Linux 4.4.0-210-generic)
04:31:05  CPU=amd64 (4 logical CPUs) (0x5e2f20000 RAM)
04:31:05  ----------- Stack Backtrace -----------
04:31:05  walkStackFrames+0x909 (0x00007FC5ADDC7A59 [libj9vm29.so+0x87a59])
04:31:05  _ZN32VM_BytecodeInterpreterCompressed3runEP10J9VMThread+0xec4d (0x00007FC5ADE00BCD [libj9vm29.so+0xc0bcd])
04:31:05  bytecodeLoopCompressed+0xca (0x00007FC5ADDF1F6A [libj9vm29.so+0xb1f6a])
04:31:05   (0x00007FC5ADEBDDE2 [libj9vm29.so+0x17dde2])
@pshipton pshipton added jdk24 segfault Issues that describe segfaults / JVM crashes test failure labels Jan 25, 2025
@pshipton pshipton added this to the Java 24 (0.50) milestone Jan 25, 2025
@pshipton pshipton changed the title jdk24 OpenJDK java/foreign/TestLinker jdk24 OpenJDK java/foreign/TestLinker crash vmState=0x00000000 Jan 25, 2025
@pshipton
Copy link
Member Author

Exclude it via adoptium/aqa-tests#5912

@babsingh
Copy link
Contributor

@h3110n3rv3 Please take a look at this issue.

@babsingh
Copy link
Contributor

babsingh commented Jan 31, 2025

@h3110n3rv3 i was looking at this failure earlier this week. here are a few insights about the failure.

gdb stack trace:

#13 walkBytecodeFrame (walkState=0x3de900) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/swalk.c:999
#14 walkStackFrames (currentThread=<optimized out>, walkState=0x3de900) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/swalk.c:353
#15 0x00007f6e18ef0fe1 in VM_BytecodeInterpreterCompressed::inlThrowableFillInStackTrace (_pc=<optimized out>, _sp=<optimized out>, this=<optimized out>) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/BytecodeInterpreter.hpp:3242
#16 VM_BytecodeInterpreterCompressed::run (this=0x6, this@entry=0x7f6e0028ae30, vmThread=0x0) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/BytecodeInterpreter.hpp:10729
#17 0x00007f6e18ee5039 in bytecodeLoopCompressed (currentThread=<optimized out>) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/BytecodeInterpreter.inc:112
#18 0x00007f6e18fb16f2 in c_cInterpreter () at /root/openj9-openjdk-jdk24/build/linux-x86_64-server-release/vm/runtime/vm/xcinterp.s:157
#19 0x00007f6e18e4e99a in internalSendExceptionConstructor (currentThread=currentThread@entry=0x3de600, exceptionClass=0x7f6e190799d0 <throwableNameAndSig>, exception=0xffe38098, detailMessage=<optimized out>, detailMessage@entry=0x0, constructorIndex=<optimized out>,
    constructorIndex@entry=0) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/callin.cpp:639
#20 0x00007f6e18e673b7 in internalSetCurrentExceptionWithCause (currentThread=0x3de600, exceptionNumber=<optimized out>, detailMessage=0x0, utfMessage=<optimized out>, cause=<optimized out>) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/exceptionsupport.c:725
#21 0x00007f6e18e67967 in setCurrentExceptionWithUtfCause (currentThread=<optimized out>, exceptionNumber=<optimized out>, detailMessage=<optimized out>, utfMessage=<optimized out>, cause=<optimized out>) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/exceptionsupport.c:807
#22 0x00007f6e18ea53ec in OutOfLineINL_openj9_internal_foreign_abi_InternalDowncallHandler_initCifNativeThunkData (currentThread=0x3de600, method=<optimized out>)
    at /root/openj9-openjdk-jdk24/openj9/runtime/vm/OutOfLineINL_openj9_internal_foreign_abi_InternalDowncallHandler.cpp:191
#23 0x00007f6e18ee7a49 in VM_BytecodeInterpreterCompressed::outOfLineINL (_pc=<optimized out>, _sp=<optimized out>, this=<optimized out>) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/BytecodeInterpreter.hpp:5613
#24 VM_BytecodeInterpreterCompressed::run (this=0x6, this@entry=0x7f6e0028b8f0, vmThread=0x0) at /root/openj9-openjdk-jdk24/openj9/runtime/vm/BytecodeInterpreter.hpp:10931
...

The segfault happens while throwing an InternalError from

if (FFI_OK != status) {
rc = GOTO_THROW_CURRENT_EXCEPTION;
setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGINTERNALERROR, NULL);
goto freeAllMemoryThenExit;
}

The following test code crashes: TestLinker.java#L254-L260

        if (linker.getClass().equals(FallbackLinker.class)) {
            // The fallback linker does not support empty layouts (FFI_BAD_TYPEDEF)
            var iae = expectThrows(IllegalArgumentException.class, () -> linker.downcallHandle(fd));
            assertTrue(iae.getMessage().contains("is empty"));
        } else {
            linker.downcallHandle(fd);
        }

The test expects an IllegalArgumentException but OpenJ9 throws an InternalError.

For the above test case, we can throw an IllegalArgumentException in OpenJ9 by changing the below code:

 	// InternalError changed to IllegalArgumentException
 	setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGILLEGALARGUMENTEXCEPTION, NULL); 

The segfault will still happen while throwing the exception.

To resolve the segfault, my initial premise was that we need to buildInternalNativeStackFrame before throwing an error/exception similar to other functions in *InternalDowncallHandler.cpp:

VM_OutOfLineINL_Helpers::buildInternalNativeStackFrame(currentThread, method);
VM_VMHelpers::pushObjectInSpecialFrame(currentThread, nativeMH);
invokeCache = resolveFfiCallInvokeHandle(currentThread, nativeMH);
nativeMH = VM_VMHelpers::popObjectInSpecialFrame(currentThread);
if (VM_VMHelpers::exceptionPending(currentThread)) {
rc = GOTO_THROW_CURRENT_EXCEPTION;
goto done;
}
VM_AtomicSupport::writeBarrier();
J9VMJAVALANGINVOKENATIVEMETHODHANDLE_SET_INVOKECACHE(currentThread, nativeMH, invokeCache);
VM_OutOfLineINL_Helpers::restoreInternalNativeStackFrame(currentThread);

Building an internal native stack frame in *InternalDowncallHandler_initCifNativeThunkData led to a different segfault. We are probably missing some preliminary setup before throwing the exception. You will need to figure out the missing piece.

h3110n3rv3 pushed a commit to h3110n3rv3/openj9 that referenced this issue Feb 6, 2025
The changes reflect the fix for issue eclipse-openj9#21017.

Cleared any pending exception before setting another.

Closes: eclipse-openj9#21017
Signed-off-by: Nick Kamal <[email protected]>
h3110n3rv3 pushed a commit to h3110n3rv3/openj9 that referenced this issue Feb 11, 2025
The changes reflect the fix for issue eclipse-openj9#21017.

Cleared any pending exception before setting another.

Closes: eclipse-openj9#21017
Signed-off-by: Nick Kamal <[email protected]>
h3110n3rv3 pushed a commit to h3110n3rv3/openj9 that referenced this issue Feb 11, 2025
The changes reflect the fix for issue eclipse-openj9#21017.

Cleared any pending exception before setting another.

Closes: eclipse-openj9#21017
Signed-off-by: Nick Kamal <[email protected]>

revert change

prints

revert

revert+test

prints

remove goto

crash fix
h3110n3rv3 pushed a commit to h3110n3rv3/openj9 that referenced this issue Feb 11, 2025
The changes reflect the fix for issue eclipse-openj9#21017.

Cleared any pending exception before setting another.

Closes: eclipse-openj9#21017
Signed-off-by: Nick Kamal <[email protected]>

revert change

prints

revert

revert+test

prints

remove goto

crash fix
h3110n3rv3 pushed a commit to h3110n3rv3/openj9 that referenced this issue Feb 11, 2025
The changes reflect the fix for issue eclipse-openj9#21017.

buildInternalNativeStackFrame before setting exception

Closes: eclipse-openj9#21017
Signed-off-by: Nick Kamal <[email protected]>
h3110n3rv3 pushed a commit to h3110n3rv3/openj9 that referenced this issue Feb 11, 2025
The changes reflect the fix for issue eclipse-openj9#21017.

buildInternalNativeStackFrame before setting exception

Closes: eclipse-openj9#21017
Signed-off-by: Nick Kamal <[email protected]>
h3110n3rv3 pushed a commit to h3110n3rv3/openj9 that referenced this issue Feb 11, 2025
The changes reflect the fix for issue eclipse-openj9#21017.

buildInternalNativeStackFrame before setting exception

Closes: eclipse-openj9#21017
Signed-off-by: Nick Kamal <[email protected]>

Revert "WIP:OpenJDK java/foreign/TestLinker crash fix"

This reverts commit b08dccc.
@babsingh babsingh reopened this Feb 24, 2025
@babsingh
Copy link
Contributor

@h3110n3rv3 Can you open a PR to re-enable TestLinker? See adoptium/aqa-tests#5967 for an example.

@babsingh
Copy link
Contributor

babsingh commented Feb 28, 2025

Test re-enabled via adoptium/aqa-tests#5974.

@h3110n3rv3 After enabling the test, the next steps are to remove the test excluded label and then close the issue. For future issues, I encourage you to try executing these steps independently. If you don’t have the necessary permissions to add or remove labels, you can request access through @AdamBrousseau.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:vm jdk24 segfault Issues that describe segfaults / JVM crashes test failure
Projects
None yet
2 participants