Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6800721
Votes 0
Synopsis JavaThread::jvmti_thread_state() and JvmtiThreadState::state_for() robustness
Category hotspot:jvmti
Reported Against b10
Release Fixed hs15(b03), hs14(b12) (Bug ID:2173781) , 6u14(b03) (Bug ID:2174068) , 7(b51) (Bug ID:2174466)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs 6700114
Submit Date 03-FEB-2009
Description
Some JavaThread::jvmti_thread_state()/JvmtiThreadState::state_for()
callers are written correctly:

src/share/vm/prims/jni.cpp: jni_ExceptionClear()

   620    JvmtiThreadState *state = JavaThread::current()->jvmti_thread_state();
   621    if (state != NULL && state->is_exception_detected()) {
   622      state->set_exception_caught();
   623    }


And some JavaThread::jvmti_thread_state()/JvmtiThreadState::state_for()
callers assume that NULL can never be returned:

src/share/vm/prims/jvmtiEnv.cpp: JvmtiEnv::SetThreadLocalStorage()

   100      // otherwise, create the state
   101      state = JvmtiThreadState::state_for(java_thread);
   102    }
   103    state->env_thread_state(this)->set_agent_thread_local_storage_data((void*)data);
Posted Date : 2009-02-03 17:43:00.0
Work Around
N/A
Evaluation
Some of the NULL checks need to return an error code:

 101     state = JvmtiThreadState::state_for(java_thread);
 102     if (state == NULL) {
 103       return JVMTI_ERROR_THREAD_NOT_ALIVE;
 104     }

Some of the state_for() calls and new error code return checks
are moved above the check that returns
JVMTI_ERROR_THREAD_NOT_SUSPENDED. I think it makes sense to
check for liveness before suspension and return the error codes
in that order; an exiting thread won't show up as being not
suspended.

Some of the NULL checks need to return a benign value:

 481   if (state == NULL) {
 482     // associated JavaThread is exiting
 483     return (jlong)0;
 484   }

Some of the NULL checks are guarantee() calls since a NULL
JvmtiThreadState value shouldn't happen in that location, i.e.,
when the caller is the current thread, it can't be exiting.
Posted Date : 2009-02-10 23:23:47.0

http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/ea20d7ce26b0
Posted Date : 2009-03-03 05:50:46.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang