<div dir="ltr">Hi Volker,<div><br></div><div>I have also come across the crash at VM exit. It happens when the path specified by CachedCodeFile includes a directory.</div><div>This is the patch I am using to fix it:</div><div><br></div><div>---</div><div><br></div><div>diff --git a/src/hotspot/share/code/SCCache.cpp b/src/hotspot/share/code/SCCache.cpp<br>index dff1090d9fd..c3c91130c52 100644<br>--- a/src/hotspot/share/code/SCCache.cpp<br>+++ b/src/hotspot/share/code/SCCache.cpp<br>@@ -109,9 +109,9 @@ void SCCache::initialize() {<br> char* cp = NEW_C_HEAP_ARRAY(char, len+1, mtCode);<br> memcpy(cp, CachedCodeFile, len);<br> cp[len] = '\0';<br>- const int file_separator = *os::file_separator();<br>- const char* start = strrchr(cp, file_separator);<br>- const char* path = (start == nullptr) ? cp : (start + 1);<br>+ //const int file_separator = *os::file_separator();<br>+ //const char* start = strrchr(cp, file_separator);<br>+ const char* path = cp;<br> <br> if (!open_cache(path)) {<br> FREE_C_HEAP_ARRAY(char, cp);</div><div><br></div><div>---</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>So maybe on Slide 1 the "Samples:" link should read:<br>Samples: <a href="https://github.com/openjdk/leyden/tree/premain/test/hotspot/jtreg/premain-precompile" rel="noreferrer" target="_blank">https://github.com/openjdk/leyden/tree/premain/test/hotspot/jtreg/premain-precompile<br></a>But then "premain-precompile" has no<br>"test/hotspot/jtreg/premain/spring-petclinic" directory ?</blockquote><div> </div><div>test/hotspot/jtreg/premain/spring-petclinic is recently pushed to premain branch [0].<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>-Xlog:scc doesn't exist in the premain branch, only -Xlog:sca. But<br>the "premain-precompile" branch has -Xlog:scc</blockquote><div><br></div><div>I haven't tried premain-precompile, but with premain -Xlog:scc* to get the logs.</div><div>FWIW I am following the steps in premain-run.sh [1] and it works for me.</div><div><br></div><div>[0] <a href="https://github.com/openjdk/leyden/tree/premain/test/hotspot/jtreg/premain/spring-petclinic">https://github.com/openjdk/leyden/tree/premain/test/hotspot/jtreg/premain/spring-petclinic</a></div><div>[1] <a href="https://github.com/openjdk/leyden/blob/premain/test/hotspot/jtreg/premain/lib/premain-run.sh">https://github.com/openjdk/leyden/blob/premain/test/hotspot/jtreg/premain/lib/premain-run.sh</a></div><div><br></div><div>Thanks,<br><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">- Ashutosh Mehra</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 14, 2023 at 10:43 AM Volker Simonis <<a href="mailto:volker.simonis@gmail.com">volker.simonis@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Mark, Vladimir,<br>
<br>
Very interesting, thanks a lot for sharing!<br>
<br>
Unfortunately the bits don't really seem to fit together. I've tried<br>
to reproduce the example but failed for several reasons:<br>
<br>
Slide 3 / Point 2. should read:<br>
-Xshare:dump -XX:SharedClassListFile=<file> -XX:SharedArchiveFile=<file><br>
<br>
Slide 3 / Point 4.:<br>
the -XX:+StoreCachedCode/-XX:CachedCodeFile don't exist in the<br>
premain branch. I've tried with<br>
-XX:SharedCodeArchive/-XX:+StoreSharedCode instead but unfortunately<br>
got a crash at VM exit (see below).<br>
After that I switched to the "premain-precompile" branch which has<br>
-XX:+StoreCachedCode/-XX:CachedCodeFile but unfortunately it crashed<br>
with the same internal error (see below).<br>
<br>
So maybe on Slide 1 the "Samples:" link should read:<br>
Samples: <a href="https://github.com/openjdk/leyden/tree/premain/test/hotspot/jtreg/premain-precompile" rel="noreferrer" target="_blank">https://github.com/openjdk/leyden/tree/premain/test/hotspot/jtreg/premain-precompile</a><br>
But then "premain-precompile" has no<br>
"test/hotspot/jtreg/premain/spring-petclinic" directory ?<br>
<br>
Slide 19:<br>
-Xlog:scc doesn't exist in the premain branch, only -Xlog:sca. But<br>
the "premain-precompile" branch has -Xlog:scc<br>
<br>
Can you please be more specific with which exact branch of the Leyden<br>
repository these examples should work?<br>
<br>
Maybe it makes sense to put the instructions for these examples in the<br>
OpenJDK Wiki (or at least in an .md file in the repository itself)<br>
such that others can help to keep it up to date.<br>
<br>
For others interested in this specific topic, which Leyden branch do<br>
you recommend monitoring and for which branch does it make sense to<br>
submit patches?<br>
<br>
Thank you for the nice work and best regards,<br>
Volker<br>
<br>
Crash dump for "premain" branch:<br>
<br>
# Internal Error<br>
(/OpenJDK/Git/leyden/src/hotspot/share/services/mallocHeader.inline.hpp:102),<br>
pid=1968868, tid=1969187<br>
# fatal error: Not a valid malloc pointer: 0x00007ffff0034905: block<br>
address is unaligned<br>
#<br>
# JRE version: OpenJDK Runtime Environment (22.0) (slowdebug build<br>
22-internal-adhoc.simonisv.leyden)<br>
# Java VM: OpenJDK 64-Bit Server VM (slowdebug<br>
22-internal-adhoc.simonisv.leyden, mixed mode, sharing, tiered,<br>
compressed oops, compressed class ptrs, g1 gc, linux-amd64)<br>
<br>
--------------- S U M M A R Y ------------<br>
<br>
Command Line: -XX:SharedArchiveFile=/tmp/HelloSwing.jsa<br>
-XX:SharedCodeArchive=/tmp/HelloSwing.jsa_code -XX:+ReplayTraining<br>
-XX:+StoreSharedCode HelloSwing<br>
<br>
Host: xxx, Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz, 8 cores, 31G,<br>
Ubuntu 20.04.6 LTS<br>
Time: Thu Sep 14 15:55:01 2023 CEST elapsed time: 56.381265 seconds<br>
(0d 0h 0m 56s)<br>
<br>
--------------- T H R E A D ---------------<br>
<br>
Current thread (0x00007fffa00092e0): JavaThread "SIGINT handler"<br>
daemon [_thread_in_vm, id=1969187,<br>
stack(0x00007fff73eff000,0x00007fff74000000) (1028K)]<br>
<br>
Stack: [0x00007fff73eff000,0x00007fff74000000],<br>
sp=0x00007fff73ffe0f0, free space=1020k<br>
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)<br>
V [libjvm.so+0x1158f9b] MallocHeader*<br>
MallocHeader::resolve_checked_impl<void*, MallocHeader*>(void*)+0x5f<br>
(mallocHeader.inline.hpp:102)<br>
V [libjvm.so+0x1158ba8] MallocHeader::resolve_checked(void*)+0x1c<br>
(mallocHeader.inline.hpp:113)<br>
V [libjvm.so+0x1158320] MallocTracker::record_free_block(void*)+0xca<br>
(mallocTracker.cpp:179)<br>
V [libjvm.so+0x1273ba0] MemTracker::record_free(void*)+0x82<br>
(memTracker.hpp:112)<br>
V [libjvm.so+0x126f935] os::free(void*)+0x3f (os.cpp:776)<br>
V [libjvm.so+0x606be0] FreeHeap(void*)+0x1c (allocation.cpp:68)<br>
V [libjvm.so+0x367a8f] SCAFile::~SCAFile()+0xe7 (SCArchive.cpp:425)<br>
V [libjvm.so+0x366b80] SCArchive::close()+0x2a (SCArchive.cpp:179)<br>
V [libjvm.so+0xd665eb] before_exit(JavaThread*, bool)+0x1d5 (java.cpp:484)<br>
V [libjvm.so+0xe92d34] JVM_Halt+0x68 (jvm.cpp:439)<br>
C [libjava.so+0x16312] Java_java_lang_Shutdown_halt0+0x30 (Shutdown.c:41)<br>
j java.lang.Shutdown.halt0(I)V+0 java.base@22-internal<br>
j java.lang.Shutdown.halt(I)V+7 java.base@22-internal<br>
j java.lang.Shutdown.exit(I)V+16 java.base@22-internal<br>
j java.lang.Terminator$1.handle(Ljdk/internal/misc/Signal;)V+8<br>
java.base@22-internal<br>
j jdk.internal.misc.Signal$1.run()V+8 java.base@22-internal<br>
j java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5<br>
java.base@22-internal<br>
j java.lang.Thread.run()V+19 java.base@22-internal<br>
v ~StubRoutines::call_stub 0x00007fffdfdc4d59<br>
V [libjvm.so+0xd6acd7] JavaCalls::call_helper(JavaValue*,<br>
methodHandle const&, JavaCallArguments*, JavaThread*)+0x60b<br>
(javaCalls.cpp:415)<br>
V [libjvm.so+0x1280ad4] os::os_exception_wrapper(void<br>
(*)(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*),<br>
JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x3a<br>
(os_linux.cpp:4958)<br>
V [libjvm.so+0xd6a6c8] JavaCalls::call(JavaValue*, methodHandle<br>
const&, JavaCallArguments*, JavaThread*)+0x3e (javaCalls.cpp:329)<br>
V [libjvm.so+0xd696d3] JavaCalls::call_virtual(JavaValue*, Klass*,<br>
Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x1b5<br>
(javaCalls.cpp:185)<br>
V [libjvm.so+0xd697e5] JavaCalls::call_virtual(JavaValue*, Handle,<br>
Klass*, Symbol*, Symbol*, JavaThread*)+0x99 (javaCalls.cpp:191)<br>
V [libjvm.so+0xea190d] thread_entry(JavaThread*, JavaThread*)+0x92<br>
(jvm.cpp:2922)<br>
V [libjvm.so+0xd85102] JavaThread::thread_main_inner()+0x15c<br>
(javaThread.cpp:721)<br>
V [libjvm.so+0xd84f9c] JavaThread::run()+0x258 (javaThread.cpp:706)<br>
V [libjvm.so+0x15964fe] Thread::call_run()+0x1a8 (thread.cpp:217)<br>
V [libjvm.so+0x1276a3e] thread_native_entry(Thread*)+0x1bd (os_linux.cpp:783)<br>
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)<br>
j java.lang.Shutdown.halt0(I)V+0 java.base@22-internal<br>
j java.lang.Shutdown.halt(I)V+7 java.base@22-internal<br>
j java.lang.Shutdown.exit(I)V+16 java.base@22-internal<br>
j java.lang.Terminator$1.handle(Ljdk/internal/misc/Signal;)V+8<br>
java.base@22-internal<br>
j jdk.internal.misc.Signal$1.run()V+8 java.base@22-internal<br>
j java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5<br>
java.base@22-internal<br>
j java.lang.Thread.run()V+19 java.base@22-internal<br>
v ~StubRoutines::call_stub 0x00007fffdfdc4d59<br>
<br>
Crash for "premain-precompile" branch:<br>
<br>
...<br>
Stack: [0x00007ffff512a000,0x00007ffff522b000],<br>
sp=0x00007ffff52290c0, free space=1020k<br>
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)<br>
V [libjvm.so+0x1177b0f] MallocHeader*<br>
MallocHeader::resolve_checked_impl<void*, MallocHeader*>(void*)+0x5f<br>
(mallocHeader.inline.hpp:102)<br>
V [libjvm.so+0x117771c] MallocHeader::resolve_checked(void*)+0x1c<br>
(mallocHeader.inline.hpp:113)<br>
V [libjvm.so+0x1176e94] MallocTracker::record_free_block(void*)+0xca<br>
(mallocTracker.cpp:179)<br>
V [libjvm.so+0x1294f30] MemTracker::record_free(void*)+0x82<br>
(memTracker.hpp:112)<br>
V [libjvm.so+0x1290b41] os::free(void*)+0x3f (os.cpp:776)<br>
V [libjvm.so+0x60c2c6] FreeHeap(void*)+0x1c (allocation.cpp:68)<br>
V [libjvm.so+0x36aa3d] SCCache::~SCCache()+0xe7 (SCCache.cpp:420)<br>
V [libjvm.so+0x369b2e] SCCache::close()+0x2a (SCCache.cpp:174)<br>
V [libjvm.so+0xd7d64d] before_exit(JavaThread*, bool)+0x1d5 (java.cpp:491)<br>
V [libjvm.so+0xeaa4be] JVM_Halt+0x68 (jvm.cpp:459)<br>
C [libjava.so+0x16312] Java_java_lang_Shutdown_halt0+0x30 (Shutdown.c:41)<br>
j java.lang.Shutdown.halt0(I)V+0 java.base@22-internal<br>
j java.lang.Shutdown.halt(I)V+7 java.base@22-internal<br>
j java.lang.Shutdown.exit(I)V+16 java.base@22-internal<br>
j java.lang.Runtime.exit(I)V+14 java.base@22-internal<br>
j java.lang.System.exit(I)V+4 java.base@22-internal<br>
j HelloSwing.<init>([Ljava/lang/String;)V+79<br>
j HelloSwing.main([Ljava/lang/String;)V+5<br>
v ~StubRoutines::call_stub 0x00007fffdfd36d59<br>
...<br>
<br>
On Tue, Sep 12, 2023 at 10:12 PM Mark Reinhold <<a href="mailto:mark.reinhold@oracle.com" target="_blank">mark.reinhold@oracle.com</a>> wrote:<br>
><br>
> Here’s a short slide deck which Vladimir Ivanov prepared to show how to<br>
> use the AOT-optimizing features in the current Leyden premain branch<br>
> with the Spring PetClinic application:<br>
><br>
> <a href="https://openjdk.org/projects/leyden/slides/leyden-premain-petclinic-2023-09-12.pdf" rel="noreferrer" target="_blank">https://openjdk.org/projects/leyden/slides/leyden-premain-petclinic-2023-09-12.pdf</a><br>
><br>
> - Mark<br>
<br>
</blockquote></div>