Skip to content

Commit

Permalink
5815 libzpool's panic function doesn't set global panicstr, ::status …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
prakashsurya authored and ahrens committed May 16, 2015
1 parent 255ca53 commit fae6347
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
28 changes: 22 additions & 6 deletions usr/src/lib/libc/port/threads/assfail.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
/*
Expand Down
8 changes: 3 additions & 5 deletions usr/src/lib/libzpool/common/kernel.c
Expand Up @@ -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
Expand Down

0 comments on commit fae6347

Please sign in to comment.