[jdk19] RFR: 8289091: move oop safety check from SharedRuntime::get_java_tid() to JavaThread::threadObj()
Daniel D. Daugherty
dcubed at openjdk.org
Mon Jun 27 15:36:48 UTC 2022
On Mon, 27 Jun 2022 00:48:43 GMT, David Holmes <dholmes 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.
>
> src/hotspot/share/runtime/thread.cpp line 2150:
>
>> 2148: void JavaThread::print_on_error(outputStream* st, char *buf, int buflen) const {
>> 2149: st->print("%s \"%s\"", type_name(), get_thread_name_string(buf, buflen));
>> 2150: if (is_oop_safe()) {
>
> This is wrong - `is_oop_safe` only has relevance when called on the current JavaThread. It is the current thread that must be oop_safe, not the target thread we are printing.
Agreed. I had that nagging feeling when I thought about this fix
while working on chores on Sunday...
> src/hotspot/share/runtime/thread.cpp line 2213:
>
>> 2211: const char* JavaThread::get_thread_name_string(char* buf, int buflen) const {
>> 2212: const char* name_str;
>> 2213: if (is_oop_safe()) {
>
> Same comment - it is the current thread that must be oop_safe. If the target thread has exited then we will detect that via the null threadObj.
Agreed.
-------------
PR: https://git.openjdk.org/jdk19/pull/69
More information about the hotspot-runtime-dev
mailing list