From 6fb682520c3b2ebfea5eae6b5345a5a5d98ab770 Mon Sep 17 00:00:00 2001 From: iedowse Date: Sun, 15 Jun 2003 11:43:00 +0000 Subject: [PATCH] Don't overwrite the static panicstr buffer for secondary and further panics. Before revision 1.38, we used to just point panicstr at the format string if panicstr was NULL, but since we now use a static buffer for the formatted panic message, we have to be careful to only write to it during the first panic. Pointed out by: bde --- sys/kern/kern_shutdown.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 714e744ae57d..3bd35d46160a 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -507,11 +507,16 @@ panic(const char *fmt, ...) } va_start(ap, fmt); - (void)vsnprintf(buf, sizeof(buf), fmt, ap); - if (panicstr == fmt) + if (newpanic) { + (void)vsnprintf(buf, sizeof(buf), fmt, ap); panicstr = buf; + printf("panic: %s\n", buf); + } else { + printf("panic: "); + vprintf(fmt, ap); + printf("\n"); + } va_end(ap); - printf("panic: %s\n", buf); #ifdef SMP /* two separate prints in case of an unmapped page and trap */ printf("cpuid = %d; ", PCPU_GET(cpuid));