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

llvm-svn: 309854
This commit is contained in:
Kostya Serebryany 2017-08-02 18:48:45 +00:00
parent 33aef072c1
commit 1ca948a2b4
3 changed files with 19 additions and 0 deletions

View File

@ -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.*.")

View File

@ -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,

View File

@ -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];
}