Change in osmo-bts[master]: common: generate coredump and exit upon SIGABRT received

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Nov 25 18:09:17 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/21355 )


Change subject: common: generate coredump and exit upon SIGABRT received
......................................................................

common: generate coredump and exit upon SIGABRT received

Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: Ic3b7c223046a80b51f0bd70ef1b15e12e6487ad0
Fixes: OS#4865
---
M src/common/main.c
1 file changed, 13 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/55/21355/1

diff --git a/src/common/main.c b/src/common/main.c
index f75e096..16ffd1e 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -214,11 +214,11 @@
 /* FIXME: remove this once we add multi-BTS support */
 struct gsm_bts *g_bts = NULL;
 
-static void signal_handler(int signal)
+static void signal_handler(int signum)
 {
-	fprintf(stderr, "signal %u received\n", signal);
+	fprintf(stderr, "signal %u received\n", signum);
 
-	switch (signal) {
+	switch (signum) {
 	case SIGINT:
 	case SIGTERM:
 		if (!quit) {
@@ -230,6 +230,16 @@
 		quit++;
 		break;
 	case SIGABRT:
+		/* in case of abort, we want to obtain a talloc report and
+		 * then run default SIGABRT handler, who will generate coredump
+		 * and abort the process. abort() should do this for us after we
+		 * return, but program wouldn't exit if an external SIGABRT is
+		 * received.
+		 */
+		talloc_report_full(tall_bts_ctx, stderr);
+		signal(SIGABRT, SIG_DFL);
+		raise(SIGABRT);
+		break;
 	case SIGUSR1:
 	case SIGUSR2:
 		talloc_report_full(tall_bts_ctx, stderr);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/21355
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ic3b7c223046a80b51f0bd70ef1b15e12e6487ad0
Gerrit-Change-Number: 21355
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201125/f1966e4f/attachment.htm>


More information about the gerrit-log mailing list