Changeset 9997


Ignore:
Timestamp:
Jul 10, 2008, 10:24:40 AM (11 years ago)
Author:
gb
Message:

Before calling pthread_kill(), ensure that tcr->osid is non-zero
(avoid race conditions if thread exits after caller checks for this.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/thread_manager.c

    r9901 r9997  
    6161raise_thread_interrupt(TCR *target)
    6262{
     63  pthread_t thread = (pthread_t)target->osid;
    6364#ifdef DARWIN_not_yet
    6465  if (use_mach_exception_handling) {
     
    6667  }
    6768#endif
    68  return pthread_kill((pthread_t)target->osid, SIGNAL_FOR_PROCESS_INTERRUPT);
     69  if (thread != (pthread_t) 0) {
     70    return pthread_kill(thread, SIGNAL_FOR_PROCESS_INTERRUPT);
     71  }
     72  return ESRCH;
    6973}
    7074#endif
     
    180184lock_recursive_lock(RECURSIVE_LOCK m, TCR *tcr)
    181185{
    182   natural val;
    183186  if (tcr == NULL) {
    184187    tcr = get_tcr(true);
     
    232235unlock_recursive_lock(RECURSIVE_LOCK m, TCR *tcr)
    233236{
    234   int ret = EPERM, pending;
     237  int ret = EPERM;
    235238
    236239   if (tcr == NULL) {
     
    12781281{
    12791282  int suspend_count = atomic_incf(&(tcr->suspend_count));
     1283  pthread_t thread;
    12801284  if (suspend_count == 1) {
    12811285#if SUSPEND_RESUME_VERBOSE
     
    12881292    }
    12891293#endif
    1290     if (pthread_kill((pthread_t)(tcr->osid), thread_suspend_signal) == 0) {
     1294    thread = (pthread_t)(tcr->osid);
     1295    if ((thread != (pthread_t) 0) &&
     1296        (pthread_kill(thread, thread_suspend_signal) == 0)) {
    12911297      SET_TCR_FLAG(tcr,TCR_FLAG_BIT_SUSPEND_ACK_PENDING);
    12921298    } else {
Note: See TracChangeset for help on using the changeset viewer.