From: Arran Cudbard-Bell Date: Mon, 29 Oct 2018 17:08:54 +0000 (-0400) Subject: Fix invalid/spurious leaks emitted from LSAN when test processes are forked X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07430a8ec8371c523aa02c7ef854e8a9ea6fe4d2;p=thirdparty%2Ffreeradius-server.git Fix invalid/spurious leaks emitted from LSAN when test processes are forked --- diff --git a/src/lib/util/debug.c b/src/lib/util/debug.c index 614dda302fc..72d2ec1b917 100644 --- a/src/lib/util/debug.c +++ b/src/lib/util/debug.c @@ -131,6 +131,7 @@ static TALLOC_CTX *talloc_autofree_ctx; static int lsan_test_pipe[2] = {-1, -1}; static int lsan_test_pid = -1; static int lsan_state = INT_MAX; +static bool lsan_disable = false; //!< Explicitly disable LSAN /* * Some versions of lsan_interface.h are broken and don't declare @@ -165,6 +166,9 @@ int CC_HINT(used) __lsan_is_turned_off(void) { uint8_t ret = 1; + /* Disable LSAN explicitly - Used for tests involving fork() */ + if (lsan_disable) return 1; + /* Parent */ if (lsan_test_pid != 0) return 0; @@ -302,6 +306,12 @@ int fr_get_debug_state(void) int ppid = getppid(); int flags; + /* + * Disable the leak checker for this forked process + * so we don't get spurious leaks reported. + */ + lsan_disable = true; + DIAG_OFF(deprecated-declarations); flags = PT_ATTACH; DIAG_ON(deprecated-declarations);