• Andrew Morton's avatar
    [PATCH] fix task struct refcount bug · 4c0d7322
    Andrew Morton authored
    From: Manfred Spraul <manfred@colorfullife.com>
    
    (We think this might be the mystery bug which has been hanging about for
    months)
    
    
    We found a [the?] task struct refcount error: A task that dies sets
    tsk->state to TASK_ZOMBIE.  The next scheduled task checks prev->state, and
    if it's ZOMBIE, then it decrements the reference count of prev.  The
    prev->state & _ZOMBIE test is not atomic with schedule, thus if prev is
    scheduled again and dies between dropping the runqueue lock and checking
    prev->state, then the reference it dropped twice.
    
    This is possible with either preemption [schedule_tail is called by
    ret_from_fork with preemption count 1, finish_arch_switch drops it to 0] or
    profiling [profile_exit_mmap can sleep on profile_rwsem, called by
    mmdrop()] enabled.
    4c0d7322
sched.c 63.4 KB