linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: PROBLEM: possible proceses leak
@ 2003-12-08 19:34 Andrew Volkov
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Volkov @ 2003-12-08 19:34 UTC (permalink / raw)
  To: William Lee Irwin III, Linus Torvalds; +Cc: linux-kernel

Yeah, really magic, sorry for troubles.

Andrey

> 
> On Mon, 8 Dec 2003, William Lee Irwin III wrote:
> >> Heh, no wonder everyone wants to get rid of the things.
> 
> On Mon, Dec 08, 2003 at 11:09:41AM -0800, Linus Torvalds wrote:
> > No, they are all correct. No bug here, move along folks, 
> nothing to see..
> > 		Linus
> 
> Looks like I missed that bit of preempt magic the first time around
> the need_resched: path in entry.S. Easy enough to drop this one.
> 
> 
> -- wli
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: PROBLEM: possible proceses leak
@ 2003-12-08 18:45 Andrew Volkov
  2003-12-08 18:51 ` William Lee Irwin III
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Volkov @ 2003-12-08 18:45 UTC (permalink / raw)
  To: William Lee Irwin III; +Cc: linux-kernel

Yes.

And same bug in kernel/sched.c in ALL *_sleep_on

Andrey

==========================================================
--- kernel/sched.c.old	2003-12-08 21:39:08.000000000 +0300
+++ kernel/sched.c	2003-12-08 21:40:19.000000000 +0300
@@ -819,10 +819,8 @@
 void interruptible_sleep_on(wait_queue_head_t *q)
 {
 	SLEEP_ON_VAR
-
-	current->state = TASK_INTERRUPTIBLE;
-
 	SLEEP_ON_HEAD
+	current->state = TASK_INTERRUPTIBLE;
 	schedule();
 	SLEEP_ON_TAIL
 }
@@ -831,9 +829,8 @@
 {
 	SLEEP_ON_VAR
 
-	current->state = TASK_INTERRUPTIBLE;
-
 	SLEEP_ON_HEAD
+	current->state = TASK_INTERRUPTIBLE;
 	timeout = schedule_timeout(timeout);
 	SLEEP_ON_TAIL
 
@@ -844,9 +841,8 @@
 {
 	SLEEP_ON_VAR
 	
-	current->state = TASK_UNINTERRUPTIBLE;
-
 	SLEEP_ON_HEAD
+	current->state = TASK_UNINTERRUPTIBLE;
 	schedule();
 	SLEEP_ON_TAIL
 }
@@ -855,9 +851,8 @@
 {
 	SLEEP_ON_VAR
 	
-	current->state = TASK_UNINTERRUPTIBLE;
-
 	SLEEP_ON_HEAD
+	current->state = TASK_UNINTERRUPTIBLE;
 	timeout = schedule_timeout(timeout);
 	SLEEP_ON_TAIL
 

^ permalink raw reply	[flat|nested] 8+ messages in thread
* PROBLEM: possible proceses leak
@ 2003-12-08 18:01 Andrew Volkov
  2003-12-08 18:25 ` William Lee Irwin III
  2003-12-08 19:08 ` Linus Torvalds
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Volkov @ 2003-12-08 18:01 UTC (permalink / raw)
  To: linux-kernel

Hi all,

In all kernels (up to 2.6-test11) next sequence of code 
in __down/__down_interruptible function 
(arch/i386/kernel/semaphore.c) may cause processes or threads leaking.

void __down(struct semaphore * sem)
{
	struct task_struct *tsk = current;
	DECLARE_WAITQUEUE(wait, tsk);

|-----tsk->state = TASK_UNINTERRUPTIBLE;		<----- BUG: 
|          -- If "do_schedule" from kernel/schedule will calling
|              at this point, due to expire of time slice,
|              then current task will removed from run_queue,
| 		   but doesn't added to any waiting queue, and hence 
|	         will never run again. --
|	add_wait_queue_exclusive(&sem->wait, &wait);
|
|->	--- This code must be here. ---

	spin_lock_irq(&semaphore_lock);
	sem->sleepers++;
	for (;;) {
		int sleepers = sem->sleepers;

		/*
		 * Add "everybody else" into it. They aren't
		 * playing, because we own the spinlock.
		 */
		if (!atomic_add_negative(sleepers - 1, &sem->count)) {
			sem->sleepers = 0;
			break;
		}
		sem->sleepers = 1;	/* us - see -1 above */
		spin_unlock_irq(&semaphore_lock);

		schedule();
		tsk->state = TASK_UNINTERRUPTIBLE; 
		spin_lock_irq(&semaphore_lock);
	}
	spin_unlock_irq(&semaphore_lock);

--->  Must be here.
|
|	remove_wait_queue(&sem->wait, &wait);	<----- SAME BUG
------tsk->state = TASK_RUNNING;
	wake_up(&sem->wait);

This bug in all  arch/*/kernel/semaphore.c files.

Regards
Andrey Volkov






^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-12-08 19:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-08 19:34 PROBLEM: possible proceses leak Andrew Volkov
  -- strict thread matches above, loose matches on Subject: below --
2003-12-08 18:45 Andrew Volkov
2003-12-08 18:51 ` William Lee Irwin III
2003-12-08 19:09   ` Linus Torvalds
2003-12-08 19:23     ` William Lee Irwin III
2003-12-08 18:01 Andrew Volkov
2003-12-08 18:25 ` William Lee Irwin III
2003-12-08 19:08 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).