[compiler-rt] r309854 - Add new ASAN_OPTION: sleep_after_init.
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 2 11:48:46 PDT 2017
Author: kcc
Date: Wed Aug 2 11:48:45 2017
New Revision: 309854
URL: http://llvm.org/viewvc/llvm-project?rev=309854&view=rev
Log:
Add new ASAN_OPTION: sleep_after_init.
Summary: As mentioned in https://github.com/google/sanitizers/issues/834, suggested option can be handy for debugging.
Reviewers: kcc
Reviewed By: kcc
Subscribers: llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D35409
Added:
compiler-rt/trunk/test/asan/TestCases/sleep_after_init.c
Modified:
compiler-rt/trunk/lib/asan/asan_flags.inc
compiler-rt/trunk/lib/asan/asan_rtl.cc
Modified: compiler-rt/trunk/lib/asan/asan_flags.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_flags.inc?rev=309854&r1=309853&r2=309854&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.inc (original)
+++ compiler-rt/trunk/lib/asan/asan_flags.inc Wed Aug 2 11:48:45 2017
@@ -79,6 +79,10 @@ ASAN_FLAG(
"Number of seconds to sleep between printing an error report and "
"terminating the program. Useful for debugging purposes (e.g. when one "
"needs to attach gdb).")
+ASAN_FLAG(
+ int, sleep_after_init, 0,
+ "Number of seconds to sleep after AddressSanitizer is initialized. "
+ "Useful for debugging purposes (e.g. when one needs to attach gdb).")
ASAN_FLAG(bool, check_malloc_usable_size, true,
"Allows the users to work around the bug in Nvidia drivers prior to "
"295.*.")
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=309854&r1=309853&r2=309854&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Aug 2 11:48:45 2017
@@ -484,6 +484,11 @@ static void AsanInitInternal() {
}
VReport(1, "AddressSanitizer Init done\n");
+
+ if (flags()->sleep_after_init) {
+ Report("Sleeping for %d second(s)\n", flags()->sleep_after_init);
+ SleepForSeconds(flags()->sleep_after_init);
+ }
}
// Initialize as requested from some part of ASan runtime library (interceptors,
Added: compiler-rt/trunk/test/asan/TestCases/sleep_after_init.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/sleep_after_init.c?rev=309854&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/sleep_after_init.c (added)
+++ compiler-rt/trunk/test/asan/TestCases/sleep_after_init.c Wed Aug 2 11:48:45 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_asan -O2 %s -o %t
+// RUN: %env_asan_opts=sleep_after_init=1 not %run %t 2>&1 | FileCheck %s
+
+#include <stdlib.h>
+int main() {
+ // CHECK: Sleeping for 1 second
+ char *x = (char*)malloc(10 * sizeof(char));
+ free(x);
+ return x[5];
+}
More information about the llvm-commits
mailing list