Move INTERNAL ERROR... printout into smb_panic() and improve "why" string
authorAndrew Bartlett <abartlet@samba.org>
Tue, 25 Feb 2020 22:58:48 +0000 (11:58 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 27 Feb 2020 03:42:35 +0000 (03:42 +0000)
The "why" string is now eg "Signal 11: Segmentation fault" and
so more descriptive, and hopefully this will encourage the
Samba version to be included in more error reports.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/util/fault.c

index c42bc51789ae56a9f67e116227cf7b57398b5bde..a34f9eedb316579dfd1da8f456de8022520b501d 100644 (file)
@@ -71,21 +71,15 @@ report a fault
 static void fault_report(int sig)
 {
        static int counter;
+       char signal_string[128];
 
        if (counter) _exit(1);
 
        counter++;
 
-       DEBUGSEP(0);
-       DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),SAMBA_VERSION_STRING));
-       DEBUG(0,("\nIf 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);
-
-       smb_panic("internal error");
+       snprintf(signal_string, sizeof(signal_string),
+                "Signal %d: %s", sig, strsignal(sig));
+       smb_panic(signal_string);
 
        /* smb_panic() never returns, so this is really redundant */
        exit(1);
@@ -170,6 +164,15 @@ static void smb_panic_default(const char *why)
 **/
 _PUBLIC_ void smb_panic(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 "
+                "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);
+
        if (fault_state.panic_handler) {
                fault_state.panic_handler(why);
                _exit(1);