8210235: JvmtiTrace::safe_get_current_thread_name is unsafe in debug builds

Use Thread::current_or_null and handle NULL result.

Reviewed-by: coleenp
This commit is contained in:
Kim Barrett 2018-08-31 16:29:49 -04:00
parent 4d57252ee0
commit 53ac5e7fed

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -291,7 +291,7 @@ const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
// return the name of the current thread
const char *JvmtiTrace::safe_get_current_thread_name() {
if (JvmtiEnv::is_vm_live()) {
return JvmtiTrace::safe_get_thread_name(Thread::current());
return JvmtiTrace::safe_get_thread_name(Thread::current_or_null());
} else {
return "VM not live";
}