comparison src/share/vm/prims/jvmtiEventController.cpp @ 609:ea20d7ce26b0

6800721: 3/4 JavaThread::jvmti_thread_state() and JvmtiThreadState::state_for() robustness Summary: Check for NULL return values from jvmti_thread_state() and state_for() and return a JVM TI error code as appropriate. Reviewed-by: coleenp, swamyv
author dcubed
date Mon, 02 Mar 2009 14:00:23 -0700
parents a61af66fc99e
children 6deeaebad47a
comparison
equal deleted inserted replaced
608:0386097d43d8 609:ea20d7ce26b0
476 476
477 // For the specified thread: compute the currently truly enabled events 477 // For the specified thread: compute the currently truly enabled events
478 // set external state accordingly. Only thread-filtered events are included. 478 // set external state accordingly. Only thread-filtered events are included.
479 jlong 479 jlong
480 JvmtiEventControllerPrivate::recompute_thread_enabled(JvmtiThreadState *state) { 480 JvmtiEventControllerPrivate::recompute_thread_enabled(JvmtiThreadState *state) {
481 if (state == NULL) {
482 // associated JavaThread is exiting
483 return (jlong)0;
484 }
485
481 jlong was_any_env_enabled = state->thread_event_enable()->_event_enabled.get_bits(); 486 jlong was_any_env_enabled = state->thread_event_enable()->_event_enabled.get_bits();
482 jlong any_env_enabled = 0; 487 jlong any_env_enabled = 0;
483 488
484 { 489 {
485 // This iteration will include JvmtiEnvThreadStates whoses environments 490 // This iteration will include JvmtiEnvThreadStates whoses environments
551 assert(JvmtiEnv::is_vm_live() || (JvmtiEnv::get_phase()==JVMTI_PHASE_START), 556 assert(JvmtiEnv::is_vm_live() || (JvmtiEnv::get_phase()==JVMTI_PHASE_START),
552 "thread filtered events should not be enabled when VM not in start or live phase"); 557 "thread filtered events should not be enabled when VM not in start or live phase");
553 { 558 {
554 MutexLocker mu(Threads_lock); //hold the Threads_lock for the iteration 559 MutexLocker mu(Threads_lock); //hold the Threads_lock for the iteration
555 for (JavaThread *tp = Threads::first(); tp != NULL; tp = tp->next()) { 560 for (JavaThread *tp = Threads::first(); tp != NULL; tp = tp->next()) {
561 // state_for_while_locked() makes tp->is_exiting() check
556 JvmtiThreadState::state_for_while_locked(tp); // create the thread state if missing 562 JvmtiThreadState::state_for_while_locked(tp); // create the thread state if missing
557 } 563 }
558 }// release Threads_lock 564 }// release Threads_lock
559 } 565 }
560 566