aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-03-05 15:46:38 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-03-05 15:49:16 +0100
commit51cd750520a2d5027b531f569372f28b838a3e6c (patch)
treefc0fd008005625230309c2cadaa5907e87dc6e19
parent4d68fd0955010625cbaa7d19cb9f69b9f44900ab (diff)
fix logging talloc ctx: add osmo_init_logging2()neels/deb9-asan
Deprecate osmo_init_logging() for the benefit of adding an explicit talloc context argument to new function osmo_init_logging2(). Before now, *all* of our code uses a NULL ctx for logging, which amounts to talloc "leaks" hit by address sanitizer builds on newer gcc (e.g. on debian 9). Passing a ctx to log_init() instead of hardcoded NULL allows fixing that. Change-Id: I216837780e9405fdaec8059c63d10699c695b360
-rw-r--r--include/osmocom/core/application.h6
-rw-r--r--src/application.c7
2 files changed, 11 insertions, 2 deletions
diff --git a/include/osmocom/core/application.h b/include/osmocom/core/application.h
index 266fa9b..b3d10e5 100644
--- a/include/osmocom/core/application.h
+++ b/include/osmocom/core/application.h
@@ -1,5 +1,7 @@
#pragma once
+#include <osmocom/core/defs.h>
+
/*!
* \file application.h
* Routines for helping with the osmocom application setup.
@@ -15,6 +17,8 @@ struct log_target;
extern struct log_target *osmo_stderr_target;
void osmo_init_ignore_signals(void);
-int osmo_init_logging(const struct log_info *);
+int osmo_init_logging(const struct log_info *)
+ OSMO_DEPRECATED("use osmo_init_logging2() instead to avoid a NULL talloc ctx");
+int osmo_init_logging2(const struct log_info *log_info, void *ctx);
int osmo_daemonize(void);
diff --git a/src/application.c b/src/application.c
index 2d237e2..8ec9470 100644
--- a/src/application.c
+++ b/src/application.c
@@ -114,13 +114,18 @@ void osmo_init_ignore_signals(void)
*/
int osmo_init_logging(const struct log_info *log_info)
{
+ return osmo_init_logging2(log_info, NULL);
+}
+
+int osmo_init_logging2(const struct log_info *log_info, void *ctx)
+{
static int logging_initialized = 0;
if (logging_initialized)
return -EEXIST;
logging_initialized = 1;
- log_init(log_info, NULL);
+ log_init(log_info, ctx);
osmo_stderr_target = log_target_create_stderr();
if (!osmo_stderr_target)
return -1;