[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Feb 27 05:10:05 UTC 2020


The branch, master has been updated
       via  f7fe6fa5505 lib/util/fault.c: Unify printing of the stack trace with the INTERNAL ERROR string
       via  4ee326f31d1 Move INTERNAL ERROR... printout into smb_panic() and improve "why" string
       via  f50bd0d0509 lib/tfork: Improve process titles for the tfork waiter process
       via  3136d2fd957 s4-smbd: Make use of prctl_set_comment()
       via  efb3aa95c5f lib/util: Make prctl_set_comment take a printf format string
      from  575d39048e3 idl: limit recurion on recursive elements

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f7fe6fa5505bddb6d7bb4a571f61ecb35e9a59dd
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Feb 26 12:02:36 2020 +1300

    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 <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Feb 27 05:09:44 UTC 2020 on sn-devel-184

commit 4ee326f31d1a26e0cbe691c2948b06cefa29caf2
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Feb 26 11:58:48 2020 +1300

    Move INTERNAL ERROR... printout into smb_panic() and improve "why" string
    
    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 at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit f50bd0d0509d20cd7b689bf366897ed8800e2435
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 22 09:45:39 2020 +1300

    lib/tfork: Improve process titles for the tfork waiter process
    
    This makes it easier to understand the process graph as there is
    not a duplicate (eg) ldap[master] process for each tfork waiter.
    when useing "ps -ef -o pid,comm"
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14287
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit 3136d2fd957d7d5c9f2bcfe6c1724c77739d93f6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 22 09:07:19 2020 +1300

    s4-smbd: Make use of prctl_set_comment()
    
    This makes it possible to tell different child tasks apart on linux systems
    that have not compiled against libsetproctitle or libbsd-setproctitle.
    
    Use "ps -ef -o pid,comm" to see the tree with these titles.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14287
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit efb3aa95c5f16caea0835b117b8fb524ff2040a6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 22 09:06:19 2020 +1300

    lib/util: Make prctl_set_comment take a printf format string
    
    This makes it easier to pass a small amount of variable information
    into the buffer, to distinguish processes in the AD DC.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14287
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/fault.c                | 38 ++++++++++++++++++++++++--------------
 lib/util/fault.h                |  1 +
 lib/util/tfork.c                |  4 ++++
 lib/util/util_process.c         | 10 ++++++++--
 lib/util/util_process.h         |  4 +++-
 source3/lib/util.c              |  6 +-----
 source3/utils/regedit.c         |  1 +
 source4/smbd/process_prefork.c  | 13 +++++++++++++
 source4/smbd/process_standard.c | 12 ++++++++++++
 9 files changed, 67 insertions(+), 22 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/fault.c b/lib/util/fault.c
index c42bc51789a..b1da1bb4121 100644
--- a/lib/util/fault.c
+++ b/lib/util/fault.c
@@ -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);
@@ -128,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.
@@ -164,12 +154,32 @@ static void smb_panic_default(const char *why)
 	abort();
 }
 
+_PUBLIC_ void smb_panic_log(const char *why)
+{
+	DEBUGSEP(0);
+	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);
 		_exit(1);
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/lib/util/tfork.c b/lib/util/tfork.c
index 16ea002b87c..5a5d449ecf8 100644
--- a/lib/util/tfork.c
+++ b/lib/util/tfork.c
@@ -26,6 +26,7 @@
 #include "lib/util/sys_rw.h"
 #include "lib/util/tfork.h"
 #include "lib/util/debug.h"
+#include "lib/util/util_process.h"
 
 #ifdef HAVE_PTHREAD
 #include <pthread.h>
@@ -572,6 +573,7 @@ static pid_t tfork_start_waiter_and_worker(struct tfork_state *state,
 	 * The "waiter" child.
 	 */
 	setproctitle("tfork waiter process");
+	prctl_set_comment("tfork waiter");
 	CatchSignal(SIGCHLD, SIG_DFL);
 
 	close(status_sp_caller_fd);
@@ -603,6 +605,8 @@ static pid_t tfork_start_waiter_and_worker(struct tfork_state *state,
 		return 0;
 	}
 	state->worker_pid = pid;
+	setproctitle("tfork waiter process(%d)", pid);
+	prctl_set_comment("tfork(%d)", pid);
 
 	close(ready_pipe_worker_fd);
 
diff --git a/lib/util/util_process.c b/lib/util/util_process.c
index bde6060597e..bb5dc15fa98 100644
--- a/lib/util/util_process.c
+++ b/lib/util/util_process.c
@@ -20,15 +20,21 @@
  */
 
 #include "util_process.h"
-#include "config.h"
+#include "replace.h"
 
 #ifdef HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
 
-int prctl_set_comment(const char *comment)
+int prctl_set_comment(const char *comment_format, ...)
 {
 #if defined(HAVE_PRCTL) && defined(PR_SET_NAME)
+	char comment[16];
+	va_list ap;
+	va_start(ap, comment_format);
+	vsnprintf(comment, sizeof(comment), comment_format, ap);
+	va_end(ap);
+
 	return prctl(PR_SET_NAME, (unsigned long) comment, 0, 0, 0);
 #endif
 	return 0;
diff --git a/lib/util/util_process.h b/lib/util/util_process.h
index 6e1ef07f186..5b337d32aec 100644
--- a/lib/util/util_process.h
+++ b/lib/util/util_process.h
@@ -22,6 +22,8 @@
 #ifndef _SAMBA_UTIL_PROCESS_H
 #define _SAMBA_UTIL_PROCESS_H
 
+#include "replace.h"
+
 /**
  * @brief Set the process comment name.
  *
@@ -30,6 +32,6 @@
  *
  * @return              -1 on error, 0 on success.
  */
-int prctl_set_comment(const char *comment);
+int prctl_set_comment(const char *comment_format, ...) PRINTF_ATTRIBUTE(1,2);
 
 #endif
diff --git a/source3/lib/util.c b/source3/lib/util.c
index e9a7368b290..4d5f611ac82 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -513,7 +513,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
 	}
 
 	if (comment) {
-		prctl_set_comment(comment);
+		prctl_set_comment("%s", comment);
 	}
 
  done:
@@ -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);
 }
 
diff --git a/source4/smbd/process_prefork.c b/source4/smbd/process_prefork.c
index 5667fb5f1ef..3c93fc0ee2a 100644
--- a/source4/smbd/process_prefork.c
+++ b/source4/smbd/process_prefork.c
@@ -44,6 +44,7 @@
 #include "ldb_wrap.h"
 #include "lib/util/tfork.h"
 #include "lib/messaging/irpc.h"
+#include "lib/util/util_process.h"
 
 #define min(a, b) (((a) < (b)) ? (a) : (b))
 
@@ -290,6 +291,11 @@ static void prefork_fork_master(
 
 	pid = getpid();
 	setproctitle("task[%s] pre-fork master", service_name);
+	/*
+	 * We must fit within 15 chars of text or we will truncate, so
+	 * we put the constant part last
+	 */
+	prctl_set_comment("%s[master]", service_name);
 
 	/*
 	 * this will free all the listening sockets and all state that
@@ -690,6 +696,13 @@ static void prefork_fork_worker(struct task_server *task,
 		setproctitle("task[%s] pre-forked worker(%d)",
 			     service_name,
 			     pd->instances);
+		/*
+		 * We must fit within 15 chars of text or we will truncate, so
+		 * we put child number last
+		 */
+		prctl_set_comment("%s(%d)",
+				  service_name,
+				  pd->instances);
 		prefork_reload_after_fork();
 		if (service_details->post_fork != NULL) {
 			service_details->post_fork(task, pd);
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 139339c92ec..e0a3536f638 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -31,6 +31,7 @@
 #include "lib/messaging/messaging.h"
 #include "lib/util/debug.h"
 #include "source3/lib/messages_dgm.h"
+#include "lib/util/util_process.h"
 
 static unsigned connections_active = 0;
 static unsigned smbd_max_processes = 0;
@@ -342,6 +343,12 @@ static void standard_accept_connection(
 	pid = getpid();
 	setproctitle("task[%s] standard worker", proc_ctx->name);
 
+	/*
+	 * We must fit within 15 chars of text or we will truncate, so
+	 * we put the constant part last
+	 */
+	prctl_set_comment("%s[work]", proc_ctx->name);
+
 	/* This is now the child code. We need a completely new event_context to work with */
 
 	if (tevent_re_initialise(ev) != 0) {
@@ -501,6 +508,11 @@ static void standard_new_task(struct tevent_context *ev,
 	}
 
 	setproctitle("task[%s]", service_name);
+	/*
+	 * We must fit within 15 chars of text or we will truncate, so
+	 * we put the constant part last
+	 */
+	prctl_set_comment("%s[task]", service_name);
 
 	/*
 	 * Set up the process context to be passed through to the terminate


-- 
Samba Shared Repository



More information about the samba-cvs mailing list