[compiler-rt] r315632 - [sanitizer] Workaround a Linux kernel bug in hard_rss_limit_mb_test.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 15:24:58 PDT 2017


Author: eugenis
Date: Thu Oct 12 15:24:58 2017
New Revision: 315632

URL: http://llvm.org/viewvc/llvm-project?rev=315632&view=rev
Log:
[sanitizer] Workaround a Linux kernel bug in hard_rss_limit_mb_test.

Modified:
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc?rev=315632&r1=315631&r2=315632&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc Thu Oct 12 15:24:58 2017
@@ -2,13 +2,9 @@
 // RUN: %clangxx -O2 %s -o %t
 //
 // Run with limit should fail:
-// RUN: %env_tool_opts=hard_rss_limit_mb=100                           not %run %t >%t.log 2>&1
-// RUN: cat %t.log
-// RUN: cat %t.log | FileCheck %s
+// RUN: %env_tool_opts=hard_rss_limit_mb=100                           not %run %t 2>&1 | FileCheck %s
 // This run uses getrusage:
-// RUN: %env_tool_opts=hard_rss_limit_mb=100:can_use_proc_maps_statm=0 not %run %t >%t.log 2>&1
-// RUN: cat %t.log
-// RUN: cat %t.log | FileCheck %s
+// RUN: %env_tool_opts=hard_rss_limit_mb=100:can_use_proc_maps_statm=0 not %run %t 2>&1 | FileCheck %s
 //
 // Run w/o limit or with a large enough limit should pass:
 // RUN: %env_tool_opts=hard_rss_limit_mb=1000 %run %t
@@ -31,7 +27,10 @@ volatile char *sink[kNumAllocs];
 int main(int argc, char **argv) {
   for (int i = 0; i < kNumAllocs; i++) {
     if ((i % 1000) == 0) {
-      fprintf(stderr, "[%d]\n", i);
+      // Don't write to stderr! Doing that triggers a kernel race condition
+      // between this thread and the rss-limit thread, and may lose part of the
+      // output. See https://lkml.org/lkml/2014/2/17/324.
+      printf("[%d]\n", i);
     }
     char *x = new char[kAllocSize];
     memset(x, 0, kAllocSize);




More information about the llvm-commits mailing list