]> git.hungrycats.org Git - linux/commit
[PATCH] fix task struct refcount bug
authorAndrew Morton <akpm@osdl.org>
Thu, 14 Aug 2003 17:16:41 +0000 (10:16 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 14 Aug 2003 17:16:41 +0000 (10:16 -0700)
commit4c0d73225a5e58935ebcf64264e8aae4ed1fecd3
tree4678cfb0d2272a1fc590a8175c9468170c09f9a4
parent45ec9b9a1e6944ab39c34073c987b8d3f47404af
[PATCH] fix task struct refcount bug

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.
kernel/sched.c