RFR: 8364090: Dump JFR recording on CrashOnOutOfMemoryError [v2]
Yasumasa Suenaga
ysuenaga at openjdk.org
Sun Jul 27 02:10:01 UTC 2025
On Sat, 26 Jul 2025 16:54:33 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:
>> Yasumasa Suenaga has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Rename is_oom to emit_old_object_samples
>
> src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp line 563:
>
>> 561: LeakProfiler::emit_events(max_jlong, false, false);
>> 562: } else {
>> 563: EventShutdown e;
>
> Do you know why EventShutDown is not always emitted?
>
> Is it emitted from somewhere else, so we would get two events if we always emitted it here?
>
> I know it was this way before your change, but I’d like to understand why. We may want to add another parameter or write a comment to explain the behavior.
We have two call path to emit `EventShutdown`.
In case of the most of OOM which triggers VM shutdown (e.g. OOM happend on the last non-daemon thread), `Threads::destroy_vm()` should be called, and `Jfr::on_vm_shutdown()` would be called via `before_exit` @ java.cpp .
`Threads::destroy_vm()` @ src/hotspot/share/runtime/threads.cpp
EventShutdown e;
if (e.should_commit()) {
e.set_reason("No remaining non-daemon Java threads");
e.commit();
}
// Hang forever on exit if we are reporting an error.
if (ShowMessageBoxOnError && VMError::is_error_reported()) {
os::infinite_sleep();
}
os::wait_for_keypress_at_exit();
// run Java level shutdown hooks
thread->invoke_shutdown_hooks();
before_exit(thread);
In case of `exception_handler` - `VMError::report_and_die()` in this case - `EventShutdown` would be emitted at `post_events()`, however `LeakProfiler::emit_events()` would not be called.
I think both `EventShutdown` and LeakProfiler should be emitted when the crash happens due to `-XX:+CrashOnOutOfMemoryError`. So I will add another parameter to enforce to emit `EventShutdown` in this case.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26468#discussion_r2233594799
More information about the hotspot-jfr-dev
mailing list