[jdk19] RFR: 8289091: move oop safety check from SharedRuntime::get_java_tid() to JavaThread::threadObj() [v2]
David Holmes
dholmes at openjdk.org
Mon Jun 27 22:48:46 UTC 2022
On Mon, 27 Jun 2022 21:00:47 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:
>> A trivial move of the oop safety check from SharedRuntime::get_java_tid() to
>> JavaThread::threadObj(). Also made adjustments to the threadObj() calls in
>> JavaThread::print_on_error() and JavaThread::get_thread_name_string() so
>> that we don't get secondary crashes when a JavaThread crashes after it has
>> detached the GC barrier.
>>
>> Tested with Mach5 Tier[1-7]. A Mach5 Tier8 will be started this weekend.
>
> Daniel D. Daugherty has updated the pull request incrementally with one additional commit since the last revision:
>
> dholmes CR - check if current thread's oop access is safe.
Hi Dan,
The additional checks to avoid secondary crashes seem like a lot of effort for little benefit, afterall the windows during which they would be applicable is quite small on the thread termination path. Somewhat ironically(?) the primary need for these additional checks would be when the current thread has already performed an unsafe oop access and so hit the guarantee and is now doing the thread dump for the hs_err file. Because of that I'm going to approve this, but in general I don't like us making the code jump through hoops for these kind of secondary failure avoidance issues. The current thread is the primary interest during a crash.
Thanks.
src/hotspot/share/runtime/thread.cpp line 2151:
> 2149: st->print("%s \"%s\"", type_name(), get_thread_name_string(buf, buflen));
> 2150: Thread* current = Thread::current_or_null();
> 2151: if (current != nullptr && (!current->is_Java_thread() || JavaThread::cast(current)->is_oop_safe())) {
Just realized, we can't have a null current thread if we are calling this as that is checked at a higher level. But we should be using `current_or_null_safe()` here as we could be in a signal-handling context.
-------------
Marked as reviewed by dholmes (Reviewer).
PR: https://git.openjdk.org/jdk19/pull/69
More information about the hotspot-runtime-dev
mailing list