RFR: 8280422: thread_from_jni_environment can never return NULL [v2]

Johannes Bechberger duke at openjdk.java.net
Mon Feb 21 12:48:59 UTC 2022


On Mon, 24 Jan 2022 02:21:34 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Analysing the code and its use (see JBS issue for gory details) we can see that `thread_from_jni_environment` can never actually return NULL, so we change it to not appear to do so and thus keep static analysis tools happy.  We also always validate the incoming JNIEnv for debug builds and scrap the unused `VerifyJNIEnvThread` flag.
>> 
>> Testing: tiers 1-5
>> 
>> Thanks,
>> David
>
> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update copyright

AsyncGetCallTrace is implemented in [forte.cpp](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/prims/forte.cpp):


void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
  JavaThread* thread;

  if (trace->env_id == NULL ||
    (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
    thread->is_exiting()) {

    // bad env_id, thread has exited or thread is exiting
    trace->num_frames = ticks_thread_exit; // -8
    return;
  }


I'm going to create a separate issue with a PR for the discussion.

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

PR: https://git.openjdk.java.net/jdk/pull/7193


More information about the hotspot-runtime-dev mailing list