[llvm-branch-commits] [compiler-rt-branch] r340801 - Merging r340758 and r340769:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 28 01:10:27 PDT 2018


Author: hans
Date: Tue Aug 28 01:10:27 2018
New Revision: 340801

URL: http://llvm.org/viewvc/llvm-project?rev=340801&view=rev
Log:
Merging r340758 and r340769:
------------------------------------------------------------------------
r340758 | vitalybuka | 2018-08-27 19:26:28 +0200 (Mon, 27 Aug 2018) | 5 lines

Revert "[lsan] Do not check for leaks in the forked process"

Users need leak reports in forks.

This reverts commit r334036.
------------------------------------------------------------------------

------------------------------------------------------------------------
r340769 | vitalybuka | 2018-08-27 21:15:05 +0200 (Mon, 27 Aug 2018) | 3 lines

[lsan] Check that leak sanitizer works in the forked process

Regression test for PR38698
------------------------------------------------------------------------

Added:
    compiler-rt/branches/release_70/test/lsan/TestCases/Linux/fork_and_leak.cc
      - copied unchanged from r340769, compiler-rt/trunk/test/lsan/TestCases/Linux/fork_and_leak.cc
Removed:
    compiler-rt/branches/release_70/test/lsan/TestCases/Linux/fork_with_threads.cc
Modified:
    compiler-rt/branches/release_70/   (props changed)
    compiler-rt/branches/release_70/lib/lsan/lsan_common.cc

Propchange: compiler-rt/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 28 01:10:27 2018
@@ -1 +1 @@
-/compiler-rt/trunk:338577,338606,339303
+/compiler-rt/trunk:338577,338606,339303,340758,340769

Modified: compiler-rt/branches/release_70/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_70/lib/lsan/lsan_common.cc?rev=340801&r1=340800&r2=340801&view=diff
==============================================================================
--- compiler-rt/branches/release_70/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/branches/release_70/lib/lsan/lsan_common.cc Tue Aug 28 01:10:27 2018
@@ -100,8 +100,6 @@ static SuppressionContext *GetSuppressio
 
 static InternalMmapVector<RootRegion> *root_regions;
 
-static uptr initialized_for_pid;
-
 InternalMmapVector<RootRegion> const *GetRootRegions() { return root_regions; }
 
 void InitializeRootRegions() {
@@ -115,7 +113,6 @@ const char *MaybeCallLsanDefaultOptions(
 }
 
 void InitCommonLsan() {
-  initialized_for_pid = internal_getpid();
   InitializeRootRegions();
   if (common_flags()->detect_leaks) {
     // Initialization which can fail or print warnings should only be done if
@@ -571,12 +568,6 @@ static void CheckForLeaksCallback(const
 static bool CheckForLeaks() {
   if (&__lsan_is_turned_off && __lsan_is_turned_off())
       return false;
-  if (initialized_for_pid != internal_getpid()) {
-    // If process was forked and it had threads we fail to detect references
-    // from other threads.
-    Report("WARNING: LeakSanitizer is disabled in forked process.\n");
-    return false;
-  }
   EnsureMainThreadIDIsCorrect();
   CheckForLeaksParam param;
   param.success = false;

Removed: compiler-rt/branches/release_70/test/lsan/TestCases/Linux/fork_with_threads.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_70/test/lsan/TestCases/Linux/fork_with_threads.cc?rev=340800&view=auto
==============================================================================
--- compiler-rt/branches/release_70/test/lsan/TestCases/Linux/fork_with_threads.cc (original)
+++ compiler-rt/branches/release_70/test/lsan/TestCases/Linux/fork_with_threads.cc (removed)
@@ -1,35 +0,0 @@
-// Test forked process does not run lsan.
-// RUN: %clangxx_lsan %s -o %t && %run %t 2>&1 | FileCheck %s
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-static pthread_barrier_t barrier;
-
-// CHECK-NOT: SUMMARY: {{(Leak|Address)}}Sanitizer:
-static void *thread_func(void *arg) {
-  void *buffer = malloc(1337);
-  pthread_barrier_wait(&barrier);
-  for (;;)
-    pthread_yield();
-  return 0;
-}
-
-int main() {
-  pthread_barrier_init(&barrier, 0, 2);
-  pthread_t tid;
-  int res = pthread_create(&tid, 0, thread_func, 0);
-  pthread_barrier_wait(&barrier);
-  pthread_barrier_destroy(&barrier);
-
-  pid_t pid = fork();
-  if (pid > 0) {
-    int status = 0;
-    waitpid(pid, &status, 0);
-  }
-  return 0;
-}
-
-// CHECK: WARNING: LeakSanitizer is disabled in forked process




More information about the llvm-branch-commits mailing list