From cf1eb58d6723ca3856687bf52167455eece2a260 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 4 Dec 2024 08:11:33 +0000 Subject: [PATCH] 8344935: [ubsan]: javaThread.hpp:1241:52: runtime error: load of value 9831830, which is not a valid value for type 'freeze_result' Co-authored-by: Richard Reingruber Reviewed-by: rrich, pchilanomate --- src/hotspot/share/runtime/continuationFreezeThaw.cpp | 7 ++++++- src/hotspot/share/runtime/javaThread.cpp | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 18beb10f0b4..a6c8e64e55e 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -256,7 +256,9 @@ public: using OopT = std::conditional_t; static freeze_result freeze(JavaThread* thread, intptr_t* const sp) { - return freeze_internal(thread, sp); + freeze_result res = freeze_internal(thread, sp); + JFR_ONLY(assert((res == freeze_ok) || (res == thread->last_freeze_fail_result()), "freeze failure not set")); + return res; } static freeze_result freeze_preempt(JavaThread* thread, intptr_t* const sp) { @@ -1722,6 +1724,9 @@ static inline freeze_result freeze_internal(JavaThread* current, intptr_t* const log_develop_debug(continuations)("PINNED due to critical section/hold monitor"); verify_continuation(cont.continuation()); freeze_result res = entry->is_pinned() ? freeze_pinned_cs : freeze_pinned_monitor; + if (!preempt) { + JFR_ONLY(current->set_last_freeze_fail_result(res);) + } log_develop_trace(continuations)("=== end of freeze (fail %d)", res); // Avoid Thread.yield() loops without safepoint polls. if (SafepointMechanism::should_process(current) && !preempt) { diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index fd9f75c41b4..5123ab69ff3 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -518,6 +518,10 @@ JavaThread::JavaThread(MemTag mem_tag) : _SleepEvent(ParkEvent::Allocate(this)), +#if INCLUDE_JFR + _last_freeze_fail_result(freeze_ok), +#endif + _lock_stack(this), _om_cache(this) { set_jni_functions(jni_functions()); @@ -2361,4 +2365,4 @@ void JavaThread::post_vthread_pinned_event(EventVirtualThreadPinned* event, cons event->commit(); } } -#endif \ No newline at end of file +#endif