RFR: 8289091: move oop safety check from SharedRuntime::get_java_tid() to JavaThread::threadObj()

David Holmes dholmes at openjdk.org
Mon Jun 27 00:54:44 UTC 2022


On Fri, 24 Jun 2022 19:53:31 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.

Main change is fine but the "other adjustments" are not correct/appropriate. The state of the target thread is not the issue.

Thanks.

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.

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.

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

Changes requested by dholmes (Reviewer).

PR: https://git.openjdk.org/jdk19/pull/69


More information about the hotspot-runtime-dev mailing list