All of lore.kernel.org
 help / color / mirror / Atom feed
* Recursive deadlock on die_lock
@ 2001-10-14  4:25 Keith Owens
  2001-10-14  6:42 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Keith Owens @ 2001-10-14  4:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton

Typical die() code.

spinlock_t die_lock = SPIN_LOCK_UNLOCKED;

void die(const char * str, struct pt_regs * regs, long err)
{
        console_verbose();
        spin_lock_irq(&die_lock);
        bust_spinlocks(1);
        printk("%s: %04lx\n", str, err & 0xffff);
        show_registers(regs);
        bust_spinlocks(0);
        spin_unlock_irq(&die_lock);
        do_exit(SIGSEGV);
}

If show_registers() fails (which it does far too often on IA64) then
the system deadlocks trying to recursively obtain die_lock.  Also
die_lock is never used outside die(), it should be proc local.
Suggested fix:

void die(const char * str, struct pt_regs * regs, long err)
{
	static spinlock_t die_lock = SPIN_LOCK_UNLOCKED;
	static int die_lock_owner = -1, die_lock_owner_depth = 0;

	if (die_lock_owner != smp_processor_id()) {
		console_verbose();
		spin_lock_irq(&die_lock);
		die_lock_owner = smp_processor_id();
		die_lock_owner_depth = 0;
		bust_spinlocks(1);
	}

	if (++die_lock_owner_depth < 3) {
		printk("%s: %04lx\n", str, err & 0xffff);
		show_registers(regs);
	}
	else
		printk(KERN_ERR "Recursive die() failure, registers suppressed\n");

	bust_spinlocks(0);
	die_lock_owner = -1;
	spin_unlock_irq(&die_lock);
        do_exit(SIGSEGV);
}


^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <fa.k3c2fuv.1q26ra4@ifi.uio.no>]

end of thread, other threads:[~2001-10-15  1:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-14  4:25 Recursive deadlock on die_lock Keith Owens
2001-10-14  6:42 ` Andrew Morton
2001-10-14  7:13   ` Keith Owens
2001-10-14 23:14     ` Eric W. Biederman
2001-10-15  0:42       ` Keith Owens
     [not found] <fa.k3c2fuv.1q26ra4@ifi.uio.no>
     [not found] ` <fa.idkv82v.3jcuip@ifi.uio.no>
2001-10-15  1:55   ` Sam Varshavchik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.