[llvm-commits] [compiler-rt] r149306 - in /compiler-rt/trunk/lib/asan: asan_internal.h asan_posix.cc asan_rtl.cc tests/test_output.sh
Kostya Serebryany
kcc at google.com
Mon Jan 30 16:52:18 PST 2012
Author: kcc
Date: Mon Jan 30 18:52:18 2012
New Revision: 149306
URL: http://llvm.org/viewvc/llvm-project?rev=149306&view=rev
Log:
[asan] new run-time flag: sleep_before_dying (asan Issue #31)
Modified:
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_posix.cc
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/tests/test_output.sh
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=149306&r1=149305&r2=149306&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Mon Jan 30 18:52:18 2012
@@ -166,6 +166,7 @@
extern size_t FLAG_max_malloc_fill_size;
extern int FLAG_exitcode;
extern bool FLAG_allow_user_poisoning;
+extern int FLAG_sleep_before_dying;
extern bool FLAG_handle_segv;
extern int asan_inited;
Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=149306&r1=149305&r2=149306&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Mon Jan 30 18:52:18 2012
@@ -70,6 +70,10 @@
}
void AsanDie() {
+ if (FLAG_sleep_before_dying) {
+ Report("Sleeping for %d second(s)\n", FLAG_sleep_before_dying);
+ sleep(FLAG_sleep_before_dying);
+ }
_exit(FLAG_exitcode);
}
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=149306&r1=149305&r2=149306&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Mon Jan 30 18:52:18 2012
@@ -47,6 +47,7 @@
bool FLAG_use_fake_stack;
int FLAG_exitcode = EXIT_FAILURE;
bool FLAG_allow_user_poisoning;
+int FLAG_sleep_before_dying;
// -------------------------- Globals --------------------- {{{1
int asan_inited;
@@ -411,6 +412,7 @@
FLAG_exitcode = IntFlagValue(options, "exitcode=", EXIT_FAILURE);
FLAG_allow_user_poisoning = IntFlagValue(options,
"allow_user_poisoning=", 1);
+ FLAG_sleep_before_dying = IntFlagValue(options, "sleep_before_dying=", 0);
if (FLAG_atexit) {
atexit(asan_atexit);
Modified: compiler-rt/trunk/lib/asan/tests/test_output.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/test_output.sh?rev=149306&r1=149305&r2=149306&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/test_output.sh (original)
+++ compiler-rt/trunk/lib/asan/tests/test_output.sh Mon Jan 30 18:52:18 2012
@@ -19,6 +19,11 @@
./a.out 2>&1 | grep "heap-use-after-free" > /dev/null
rm ./a.out
+echo "Testing sleep_before_dying"
+$CC -g -faddress-sanitizer -O2 $C_TEST.c
+ASAN_OPTIONS=sleep_before_dying=1 ./a.out 2>&1 | grep "Sleeping for 1 second" > /dev/null
+rm a.out
+
for t in *.tmpl; do
for b in 32 64; do
for O in 0 1 2 3; do
More information about the llvm-commits
mailing list