2.1.115: Small bug in do_exit() ?

Jean Wolter (jw5@os.inf.tu-dresden.de)
12 Aug 1998 15:47:30 +0200


Hello,

while searching for a possible reason for my 'process 0 running on
processor 3' problem I found a small bug in do_exit (at least I think
it is one).

If an interrupt handler raises an oops in the context of process 0 we
panic, since we can't kill our idle task.

If the oops happens on any idle processor other then processor 0 we
silently kill the idle task for this processor, since the pid is not
zero.

I would propose the following patch to exit.c (it compiles, but it
isn't tested since I don't have a SMP box at the moment)

--- exit.c.orig Mon Aug 3 21:18:17 1998
+++ exit.c Wed Aug 12 11:08:19 1998
@@ -347,6 +347,11 @@
if (current->leader)
disassociate_ctty(1);
}
+#ifdef __SMP__
+#define idle_task (task[cpu_number_map[tsk->processor]])
+#else
+#define idle_task (&init_task)
+#endif

NORET_TYPE void do_exit(long code)
{
@@ -354,7 +359,7 @@

if (in_interrupt())
printk("Aiee, killing interrupt handler\n");
- if (!tsk->pid)
+ if (tsk == idle_task)
panic("Attempted to kill the idle task!");
tsk->flags |= PF_EXITING;
del_timer(&tsk->real_timer);

panic.c has the same problem:

--- panic.c.orig Wed Aug 12 11:10:28 1998
+++ panic.c Wed Aug 12 11:12:35 1998
@@ -31,6 +31,12 @@
panic_timeout = ints[1];
}

+#ifdef __SMP__
+#define idle_task (task[cpu_number_map[current->processor]])
+#else
+#define idle_task (&init_task)
+#endif
+
NORET_TYPE void panic(const char * fmt, ...)
{
static char buf[1024];
@@ -40,7 +46,7 @@
vsprintf(buf, fmt, args);
va_end(args);
printk(KERN_EMERG "Kernel panic: %s\n",buf);
- if (current == task[0])
+ if (current == idle_task)
printk(KERN_EMERG "In swapper task - not syncing\n");
else if (in_interrupt())
printk(KERN_EMERG "In interrupt handler - not syncing\n");

Jean

-- 
I get up each morning, gather my wits.
Pick up the paper, read the obits.
if I'm not there I know I'm not dead.
So I eat a good breakfast and go back to bed. Peete Seeger

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html