RFR: 8360164: AOT cache creation crashes in ~ThreadTotalCPUTimeClosure()

David Holmes dholmes at openjdk.org
Fri Jun 27 04:46:38 UTC 2025


On Thu, 26 Jun 2025 23:41:40 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> `java -XX:AOTMode=create` calls `vm_exit(0)` to terminate the JVM (see [this e-mail thread](https://mail.openjdk.org/pipermail/hotspot-runtime-dev/2024-August/072122.html) for the reason for doing so). However, at this point, the JVM has executed quite a lot of Java code and there are many threads in the JVM that would require a proper shutdown. See [comments by @kimbarrett](https://bugs.openjdk.org/browse/JDK-8360164?focusedId=14792754&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14792754) for a detailed analysis.
> 
> This fix calls `JVM_Halt(0)` instead of `vm_exit(0)` so that the proper shutdown code is executed.

Changes requested by dholmes (Reviewer).

src/hotspot/share/cds/metaspaceShared.cpp line 846:

> 844:       }
> 845:       ThreadToNativeFromVM ttnfv(THREAD);
> 846:       JVM_Halt(0);

`JVM_Halt` is the native backend for the JDK's `System.halt()` method. Whilst it might do what you need under-the-covers, I think it would be clearer to not actually call it, but just call `before_exit` and `vm_exit` directly. Even then you need to be careful as to how the `halt` parameter will be interpreted - in particular the affect on `Jfr::on_vm_shutdown`. In fact `before_exit` needs detailed examination to see if everything it does truly makes sense in this context.

src/hotspot/share/runtime/java.cpp line 435:

> 433:   // Dynamic CDS dumping must happen whilst we can still reliably
> 434:   // run Java code.
> 435:   if (CDSConfig::is_dumping_dynamic_archive()) {

I assume requesting a dynamic dump is mutually exclusive to the use of `-XX:AOTMode=create`?

-------------

PR Review: https://git.openjdk.org/jdk/pull/26008#pullrequestreview-2964713236
PR Review Comment: https://git.openjdk.org/jdk/pull/26008#discussion_r2170765111
PR Review Comment: https://git.openjdk.org/jdk/pull/26008#discussion_r2170766001


More information about the hotspot-runtime-dev mailing list