summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-02-11 19:07:02 +0000
committerJeremy Allison <jra@samba.org>2004-02-11 19:07:02 +0000
commit90b5adc557e54607e6a7aef273819f11982562c4 (patch)
tree702537b29ff67da9c965ab3d70f5b6269c43c4d8 /source3/lib
parent439bcaf9e716c3a22ec436abc0cce33d9ad3439b (diff)
downloadsamba-90b5adc557e54607e6a7aef273819f11982562c4.tar.gz
samba-90b5adc557e54607e6a7aef273819f11982562c4.tar.bz2
samba-90b5adc557e54607e6a7aef273819f11982562c4.zip
Added James Peach's fix for #1038.
Jeremy. (This used to be commit 5379ad98241950c581d88acbee1e256187b13582)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 3da4e536e0..e9ab72b2bf 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1344,6 +1344,10 @@ gid_t nametogid(const char *name)
Something really nasty happened - panic !
********************************************************************/
+#ifdef HAVE_LIBEXC_H
+#include <libexc.h>
+#endif
+
void smb_panic(const char *why)
{
char *cmd;
@@ -1398,6 +1402,42 @@ void smb_panic(const char *why)
SAFE_FREE(backtrace_strings);
}
+#elif HAVE_LIBEXC
+
+#define NAMESIZE 32 /* Arbitrary */
+
+ /* The IRIX libexc library provides an API for unwinding the stack. See
+ * libexc(3) for details. Apparantly trace_back_stack leaks memory, but
+ * since we are about to abort anyway, it hardly matters.
+ *
+ * Note that if we paniced due to a SIGSEGV or SIGBUS (or similar) this
+ * will fail with a nasty message upon failing to open the /proc entry.
+ */
+ {
+ __uint64_t addrs[BACKTRACE_STACK_SIZE];
+ char * names[BACKTRACE_STACK_SIZE];
+ char namebuf[BACKTRACE_STACK_SIZE * NAMESIZE];
+
+ int i;
+ int levels;
+
+ ZERO_ARRAY(addrs);
+ ZERO_ARRAY(names);
+ ZERO_ARRAY(namebuf);
+
+ for (i = 0; i < BACKTRACE_STACK_SIZE; i++) {
+ names[i] = namebuf + (i * NAMESIZE);
+ }
+
+ levels = trace_back_stack(0, addrs, names,
+ BACKTRACE_STACK_SIZE, NAMESIZE);
+
+ DEBUG(0, ("BACKTRACE: %d stack frames:\n", levels));
+ for (i = 0; i < levels; i++) {
+ DEBUGADD(0, (" #%d 0x%llx %s\n", i, addrs[i], names[i]));
+ }
+ }
+#undef NAMESIZE
#endif
dbgflush();