summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrakash Surya <prakash.surya@delphix.com>2015-05-16 11:53:51 -0700
committerMatthew Ahrens <mahrens@delphix.com>2015-05-16 11:53:51 -0700
commitfae6347731c9d3f46b26338313b0422927f29cf6 (patch)
tree5835e41705c556cda9e973dc0b4c4ad3a789ef38
parent255ca53cb863784f137aca02aa15c67d8dce73de (diff)
downloadillumos-joyent-fae6347731c9d3f46b26338313b0422927f29cf6.tar.gz
5815 libzpool's panic function doesn't set global panicstr, ::status not as useful
Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Sebastien Roy <sebastien.roy@delphix.com> Reviewed by: Gordon Ross <gordon.ross@nexenta.com> Reviewed by: Rich Lowe <richlowe@richlowe.net> Approved by: Dan McDonald <danmcd@omniti.com>
-rw-r--r--usr/src/lib/libc/port/threads/assfail.c28
-rw-r--r--usr/src/lib/libzpool/common/kernel.c8
2 files changed, 25 insertions, 11 deletions
diff --git a/usr/src/lib/libc/port/threads/assfail.c b/usr/src/lib/libc/port/threads/assfail.c
index 7a98884f4b..8aebefbe4a 100644
--- a/usr/src/lib/libc/port/threads/assfail.c
+++ b/usr/src/lib/libc/port/threads/assfail.c
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
*/
#include "lint.h"
@@ -409,16 +409,32 @@ __assfail(const char *assertion, const char *filename, int line_num)
lwpid = _lwp_self();
}
- (void) strcpy(buf, "assertion failed for thread ");
+ /*
+ * This is a hack, but since the Abort function isn't exported
+ * to outside consumers, libzpool's vpanic() function calls
+ * assfail() with a filename set to NULL. In that case, it'd be
+ * best not to print "assertion failed" since it was a panic and
+ * not an assertion failure.
+ */
+ if (filename == NULL) {
+ (void) strcpy(buf, "failure for thread ");
+ } else {
+ (void) strcpy(buf, "assertion failed for thread ");
+ }
+
ultos((uint64_t)(uintptr_t)self, 16, buf + strlen(buf));
(void) strcat(buf, ", thread-id ");
ultos((uint64_t)lwpid, 10, buf + strlen(buf));
(void) strcat(buf, ": ");
(void) strcat(buf, assertion);
- (void) strcat(buf, ", file ");
- (void) strcat(buf, filename);
- (void) strcat(buf, ", line ");
- ultos((uint64_t)line_num, 10, buf + strlen(buf));
+
+ if (filename != NULL) {
+ (void) strcat(buf, ", file ");
+ (void) strcat(buf, filename);
+ (void) strcat(buf, ", line ");
+ ultos((uint64_t)line_num, 10, buf + strlen(buf));
+ }
+
(void) strcat(buf, "\n");
(void) __write(2, buf, strlen(buf));
/*
diff --git a/usr/src/lib/libzpool/common/kernel.c b/usr/src/lib/libzpool/common/kernel.c
index 5e329733e1..dd4221deb5 100644
--- a/usr/src/lib/libzpool/common/kernel.c
+++ b/usr/src/lib/libzpool/common/kernel.c
@@ -691,11 +691,9 @@ static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
void
vpanic(const char *fmt, va_list adx)
{
- (void) fprintf(stderr, "error: ");
- (void) vfprintf(stderr, fmt, adx);
- (void) fprintf(stderr, "\n");
-
- abort(); /* think of it as a "user-level crash dump" */
+ char buf[512];
+ (void) vsnprintf(buf, 512, fmt, adx);
+ assfail(buf, NULL, 0);
}
void