]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix invalid/spurious leaks emitted from LSAN when test processes are forked
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 29 Oct 2018 17:08:54 +0000 (13:08 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 29 Oct 2018 17:08:54 +0000 (13:08 -0400)
src/lib/util/debug.c

index 614dda302fc39135d4b0f6c374066c46d740728c..72d2ec1b9170bc90d07b3b8f769f39216b5532ef 100644 (file)
@@ -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);