eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 721 forks source link

[JDK18] GetCallerClassTest Segfaults #14097

Closed babsingh closed 2 years ago

babsingh commented 2 years ago

OpenJDK Test

jdk/internal/reflect/Reflection/GetCallerClassTest.java

Errors

STDOUT:

testMissingCallerSensitiveAnnotation...
Expected error: Caller is not annotated as @sun.reflect.CallerSensitive.

testNonSystemMethod...
Expected error: Caller is not annotated as @sun.reflect.CallerSensitive.

caller: class GetCallerClassTest
Timeout refired 120 times
STDERR:
Unhandled exception
Type=Segmentation error vmState=0x00040000
J9Generic_Signal_Number=00000018 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001
Handler1=00007FFFF5F72E60 Handler2=00007FFFF5528210 InaccessibleAddress=0000000000000180
RDI=0000000000090D10 RSI=0000000000242568 RAX=00007FFFF00139C0 RBX=0000000000091080
RCX=0000000000000003 RDX=0000000000000180 R8=0000000000000001 R9=FFFFFFFF80020002
R10=00007FFFC86CC918 R11=0000000000000007 R12=0000000000000000 R13=0000000000000000
R14=0000000000000000 R15=00007FFFC86CCD90
RIP=00007FFFF5FC9B0B GS=0000 FS=0000 RSP=00007FFFC86CCA20
EFlags=0000000000010246 CS=0033 RBP=00000007FFFCCC58 ERR=0000000000000004
TRAPNO=000000000000000E OLDMASK=0000000000000000 CR2=0000000000000180
xmm0 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm1 656c75646f4d656d (f: 1867343232.000000, d: 3.690289e+180)
xmm2 ffffffffffffffff (f: 4294967296.000000, d: -nan)
xmm3 00000000001a0418 (f: 1704984.000000, d: 8.423740e-318)
xmm4 00000000001a0418 (f: 1704984.000000, d: 8.423740e-318)
xmm5 00000000001a1368 (f: 1708904.000000, d: 8.443108e-318)
xmm6 0000000000041508 (f: 267528.000000, d: 1.321764e-318)
xmm7 000000000000000d (f: 13.000000, d: 6.422853e-323)
xmm8 0000130001000c00 (f: 16780288.000000, d: 1.032140e-310)
xmm9 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm10 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm11 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm12 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm13 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm14 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm15 0000000000000000 (f: 0.000000, d: 0.000000e+00)
Module=/root/openj9-openjdk-jdk/build/linux-x86_64-server-release/images/jdk/lib/default/libj9vm29.so
Module_base_address=00007FFFF5F33000
Target=2_90_20211206_000000 (Linux 4.15.0-161-generic)
CPU=amd64 (8 logical CPUs) (0x3ea77f000 RAM)
----------- Stack Backtrace -----------
(0x00007FFFF5FC9B0B [libj9vm29.so+0x96b0b])
(0x00007FFFF5FC4D75 [libj9vm29.so+0x91d75])
(0x00007FFFF60680B2 [libj9vm29.so+0x1350b2])
---------------------------------------
JVMDUMP039I Processing dump event "gpf", detail "" at 2021/12/06 15:49:59 - please wait.
JVMDUMP032I JVM requested System dump using '/root/openj9-openjdk-jdk/JTwork/scratch/core.20211206.154959.21037.0001.dmp' in response to an event
JVMDUMP010I System dump written to /root/openj9-openjdk-jdk/JTwork/scratch/core.20211206.154959.21037.0001.dmp
JVMDUMP032I JVM requested Java dump using '/root/openj9-openjdk-jdk/JTwork/scratch/javacore.20211206.154959.21037.0002.txt' in response to an event
JVMDUMP010I Java dump written to /root/openj9-openjdk-jdk/JTwork/scratch/javacore.20211206.154959.21037.0002.txt
00000000001EA100: Object neither in heap nor stack-allocated in thread MainThread
00000000001EA100:   O-Slot=00000007FFF0DFD8
00000000001EA100:   O-Slot value=058C463B00000001
00000000001EA100:   PC=00007FFF994E4AB5
00000000001EA100:   framesWalked=1
00000000001EA100:   arg0EA=00000007FFF0DFD8
00000000001EA100:   walkSP=0000000000242568
00000000001EA100:   literals=0000000000091080
00000000001EA100:   jitInfo=0000000000000000
00000000001EA100:   method=0000000000091080 (java/lang/StackWalker$StackFrameImpl.toStackTraceElement()Ljava/lang/StackTraceElement;) (Interpreted)
00000000001EA100:   stack=000000000023BB78-0000000000242BB0
00000000001EA100: Object neither in heap nor stack-allocated in thread MainThread
00000000001EA100:   O-Slot=00000007FFF0DFD0
00000000001EA100:   O-Slot value=FFFE1C1900050010
00000000001EA100:   PC=00007FFF994E4AB5
00000000001EA100:   framesWalked=1
00000000001EA100:   arg0EA=00000007FFF0DFD8
00000000001EA100:   walkSP=0000000000242568
00000000001EA100:   literals=0000000000091080
00000000001EA100:   jitInfo=0000000000000000
00000000001EA100:   method=0000000000091080 (java/lang/StackWalker$StackFrameImpl.toStackTraceElement()Ljava/lang/StackTraceElement;) (Interpreted)
00000000001EA100:   stack=000000000023BB78-0000000000242BB0
Unhandled exception
Type=Segmentation error vmState=0x0002000f
J9Generic_Signal_Number=00000018 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000080
Handler1=00007FFFF5F72EA0 Handler2=00007FFFF5528210 InaccessibleAddress=0000000000000000
RDI=00000000FFF99747 RSI=00007FFFC8893D50 RAX=0000000000000000 RBX=0000000000000001
RCX=00007FFF5BFFF318 RDX=00000000FFF99746 R8=0000000000000001 R9=0000000000000005
R10=0000000000000001 R11=00007FFFC8893E48 R12=00007FFFC8893D50 R13=00007FFFC8893D58
R14=00007FFF994E4AB0 R15=00007FFFC8893D40
RIP=00007FFFF608251A GS=0000 FS=0000 RSP=00007FFFC8893CB0
EFlags=0000000000010246 CS=0033 RBP=0000000000000058 ERR=0000000000000000
TRAPNO=000000000000000D OLDMASK=0000000000000000 CR2=0000000000000000
xmm0 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm1 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm2 0000000000000003 (f: 3.000000, d: 1.482197e-323)
xmm3 fffe3bde00000000 (f: 0.000000, d: -nan)
xmm4 3fcbc2860d224770 (f: 220350320.000000, d: 2.168739e-01)
xmm5 00000000fffe15a3 (f: 4294841856.000000, d: 2.121934e-314)
xmm6 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm7 00000007ffdcba04 (f: 4292655616.000000, d: 1.697482e-313)
xmm8 006c002f00610076 (f: 6357110.000000, d: 1.246073e-306)
xmm9 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm10 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm11 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm12 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm13 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm14 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm15 0000000000000000 (f: 0.000000, d: 0.000000e+00)
Module=/root/openj9-openjdk-jdk/build/linux-x86_64-server-release/images/jdk/lib/default/libj9vm29.so
Module_base_address=00007FFFF5F33000
Target=2_90_20211206_000000 (Linux 4.15.0-161-generic)
CPU=amd64 (8 logical CPUs) (0x3ea77f000 RAM)
----------- Stack Backtrace -----------
(0x00007FFFF608251A [libj9vm29.so+0x14f51a])
(0x00007FFFF5FB1DCF [libj9vm29.so+0x7edcf])
(0x00007FFFF5FB2CA7 [libj9vm29.so+0x7fca7])
(0x00007FFFEEECF3B6 [libj9gc29.so+0x423b6])
(0x00007FFFEEEC73FD [libj9gc29.so+0x3a3fd])
(0x00007FFFEEEC610F [libj9gc29.so+0x3910f])
(0x00007FFFEEEC8C82 [libj9gc29.so+0x3bc82])
(0x00007FFFEF01037B [libj9gc29.so+0x18337b])
(0x00007FFFEEFBC0E7 [libj9gc29.so+0x12f0e7])
(0x00007FFFEEFBB8F9 [libj9gc29.so+0x12e8f9])
(0x00007FFFF5528F73 [libj9prt29.so+0x28f73])
(0x00007FFFEEFBB3FF [libj9gc29.so+0x12e3ff])
(0x00007FFFF5D26302 [libj9thr29.so+0xe302])
(0x00007FFFF71986DB [libpthread.so.0+0x76db])
clone+0x3f (0x00007FFFF78F271F [libc.so.6+0x12171f])
---------------------------------------
JVMDUMP039I Processing dump event "gpf", detail "" at 2021/12/06 15:50:00 - please wait.

Related: #13946

babsingh commented 2 years ago

This failure will only be seen once https://github.com/eclipse-openj9/openj9/issues/13998 is fixed via https://github.com/ibmruntimes/openj9-openjdk-jdk/pull/382.

babsingh commented 2 years ago

For JDK18, jdk/internal/reflect/Reflection/GetCallerClassTest.java is already excluded via https://github.com/adoptium/aqa-tests/pull/3154 due to https://github.com/eclipse-openj9/openj9/issues/13998.

Once #13998 is fixed via ibmruntimes/openj9-openjdk-jdk#382, ProblemList_openjdk18-openj9.txt (in the aqa-tests repo) should be updated to state that */Reflection/GetCallerClassTest.java is excluded due to this PR.

EricYangIBM commented 2 years ago

Crash occurs in https://github.com/eclipse-openj9/openj9/blob/master/jcl/src/java.base/share/classes/java/lang/StackWalker.java#L210 at function.apply(frameStream) at invokevirtualLogic

_sendMethod = *(J9Method**)((UDATA)receiverClass + methodIndex);

The function is

    private static Function<Stream<StackWalker.StackFrame>, String> toStackTrace() {
        return frames -> frames
            .takeWhile(
                frame -> !frame.getClassName().equals("GetCallerClassTest") ||
                         !frame.getMethodName().equals("main"))
            .map(Object::toString)
            .collect(Collectors.joining("\n  ", "  ", "\n"));
    }

I have tried variations e.g.

    private static Function<Stream<StackWalker.StackFrame>, List<StackWalker.StackFrame>> toStackTrace() {
        return s -> s.limit(10).collect(Collectors.toList());
    }

but it fails at the same place.

tajila commented 2 years ago

@EricYangIBM How reproduceable is this failure?

tajila commented 2 years ago

I wasnt able to reproduce it, although I wasnt running with the test harness

EricYangIBM commented 2 years ago

I have been able to reproduce it in every run (with jtreg)

tajila commented 2 years ago

I was able to reproduce the problem

tajila commented 2 years ago

The crash is caused by an issue where we put the wrong object in the StackFrameImpl::frameModule field

            J9Module *module = ramClass->module;
            if (NULL != module) {
                J9VMJAVALANGSTACKWALKERSTACKFRAMEIMPL_SET_FRAMEMODULE(vmThread, frame, module->moduleObject);
            }
tajila commented 2 years ago

In this case the j9module contains the wrong module object. When I run the test with -Xgcpolicy:nogc we do not crash. My assumption is the the module is being collected while we are performing the stackwalk

tajila commented 2 years ago

We have a difference in the original reflection implementation which means we can not re-enable all the tests. This difference exists as far back as JDK11. However, the segfaults have been fixed.

tajila commented 2 years ago

The tests have been re-included

pshipton commented 2 years ago

Removed the test excluded label and added perm excluded for the remaining tests that won't be fixed.

pshipton commented 2 years ago

@tajila this can be closed now?

tajila commented 2 years ago

Yes we can close it