On Fri, 2 Sep 2022 14:47:35 GMT, Kevin Walls <kev...@openjdk.org> wrote:

> This is an MR which partially reverts JDK-8289091 such that 
> JavaThread::threadObj() does not call Thread::current().
> 
> A JVMTI operation could call threadObj() and clear the Windows GetLastError 
> value.
> 
> Partial, because I haven't reverted changes in JavaThread::print_on_error(), 
> they aren't connected to the problems seen.

This is fine to me - modulo changing the comment as below. As I'm away on 
vacation I will pre-approve. Please be sure @dcubed-ojdk sees this before 
integrating.

Thanks.

src/hotspot/share/runtime/javaThread.cpp line 165:

> 163: oop JavaThread::threadObj() const {
> 164:   // Using Thread::current_or_null_safe() here risks that calling 
> threadObj() can
> 165:   // overwrite a native thread local, e.g. JVMTI operations clearing 
> GetLastError on Windows.

Suggestion:

// Ideally we would verify the current thread is oop_safe when this is called, 
but as we can
// be called from a signal handler we would have to use 
Thread::current_or_null_safe(). That
// has overhead and also interacts poorly with GetLastError on Windows due to 
the use of TLS.
// Instead callers must verify oop safe access.

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

Marked as reviewed by dholmes (Reviewer).

PR: https://git.openjdk.org/jdk/pull/10147

Reply via email to