From: Andrew Bartlett Date: Tue, 25 Feb 2020 23:02:36 +0000 (+1300) Subject: lib/util/fault.c: Unify printing of the stack trace with the INTERNAL ERROR string X-Git-Tag: ldb-2.2.0~1567 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7fe6fa5505bddb6d7bb4a571f61ecb35e9a59dd;p=thirdparty%2Fsamba.git lib/util/fault.c: Unify printing of the stack trace with the INTERNAL ERROR string We can diverged into the s3 and lib/fault panic action stuff once we have printed the backtrace. Our tests require we use the word PANIC, and some administrative scripts might look for similar things, so keep those words. The use of DEBUG(0, ... is deliberate to keep the output of the PANIC line as consistent as possible with the historical smbd output. Signed-off-by: Andrew Bartlett Reviewed-by: Gary Lockyer Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Thu Feb 27 05:09:44 UTC 2020 on sn-devel-184 --- diff --git a/lib/util/fault.c b/lib/util/fault.c index a34f9eedb31..b1da1bb4121 100644 --- a/lib/util/fault.c +++ b/lib/util/fault.c @@ -122,10 +122,6 @@ _PUBLIC_ const char *panic_action = NULL; static void smb_panic_default(const char *why) _NORETURN_; static void smb_panic_default(const char *why) { - DBG_ERR("PANIC (pid %llu): %s\n", - (unsigned long long)getpid(), why); - log_stack_trace(); - #if defined(HAVE_PRCTL) && defined(PR_SET_PTRACER) /* * Make sure all children can attach a debugger. @@ -158,20 +154,31 @@ static void smb_panic_default(const char *why) abort(); } - -/** - Something really nasty happened - panic ! -**/ -_PUBLIC_ void smb_panic(const char *why) +_PUBLIC_ void smb_panic_log(const char *why) { DEBUGSEP(0); - DEBUG(0,("INTERNAL ERROR: %s in pid %d (%s)",why,(int)getpid(),SAMBA_VERSION_STRING)); - DEBUG(0,("\nIf you are running a recent Samba version, and " + DEBUG(0,("INTERNAL ERROR: %s in pid %lld (%s)\n", + why, + (unsigned long long)getpid(), + SAMBA_VERSION_STRING)); + DEBUG(0,("If you are running a recent Samba version, and " "if you think this problem is not yet fixed in the " "latest versions, please consider reporting this " "bug, see " "https://wiki.samba.org/index.php/Bug_Reporting\n")); DEBUGSEP(0); + DEBUG(0,("PANIC (pid %llu): %s in " SAMBA_VERSION_STRING "\n", + (unsigned long long)getpid(), why)); + + log_stack_trace(); +} + +/** + Something really nasty happened - panic ! +**/ +_PUBLIC_ void smb_panic(const char *why) +{ + smb_panic_log(why); if (fault_state.panic_handler) { fault_state.panic_handler(why); diff --git a/lib/util/fault.h b/lib/util/fault.h index dfa339b7650..f3b1666a172 100644 --- a/lib/util/fault.h +++ b/lib/util/fault.h @@ -52,6 +52,7 @@ void fault_configure(smb_panic_handler_t panic_handler); void fault_setup(void); void fault_setup_disable(void); _NORETURN_ void smb_panic(const char *reason); +void smb_panic_log(const char *reason); void log_stack_trace(void); diff --git a/source3/lib/util.c b/source3/lib/util.c index 4b276415378..4d5f611ac82 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -826,10 +826,6 @@ void smb_panic_s3(const char *why) char *cmd; int result; - DEBUG(0,("PANIC (pid %llu): %s\n", - (unsigned long long)getpid(), why)); - log_stack_trace(); - #if defined(HAVE_PRCTL) && defined(PR_SET_PTRACER) /* * Make sure all children can attach a debugger. diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c index 2f5e0fcc1eb..ce50f657991 100644 --- a/source3/utils/regedit.c +++ b/source3/utils/regedit.c @@ -681,6 +681,7 @@ int regedit_getch(void) static void regedit_panic_handler(const char *msg) { endwin(); + smb_panic_log(msg); smb_panic_s3(msg); }