[compiler-rt] r340769 - [lsan] Check that leak sanitizer works in the forked process
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 27 12:15:05 PDT 2018
Author: vitalybuka
Date: Mon Aug 27 12:15:05 2018
New Revision: 340769
URL: http://llvm.org/viewvc/llvm-project?rev=340769&view=rev
Log:
[lsan] Check that leak sanitizer works in the forked process
Regression test for PR38698
Added:
compiler-rt/trunk/test/lsan/TestCases/Linux/fork_and_leak.cc
Added: compiler-rt/trunk/test/lsan/TestCases/Linux/fork_and_leak.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/Linux/fork_and_leak.cc?rev=340769&view=auto
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/Linux/fork_and_leak.cc (added)
+++ compiler-rt/trunk/test/lsan/TestCases/Linux/fork_and_leak.cc Mon Aug 27 12:15:05 2018
@@ -0,0 +1,23 @@
+// Test that leaks detected after forking without exec().
+// RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+int main() {
+ pid_t pid = fork();
+ assert(pid >= 0);
+ if (pid > 0) {
+ int status = 0;
+ waitpid(pid, &status, 0);
+ assert(WIFEXITED(status));
+ return WEXITSTATUS(status);
+ } else {
+ malloc(1337);
+ // CHECK: LeakSanitizer: detected memory leaks
+ }
+ return 0;
+}
+
More information about the llvm-commits
mailing list