-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sanitizer] Don't run malloc hooks for stacktraces
Usually when we generated stacktraces the process is in error state, so running hooks may crash the process and prevent meaningfull error report. Symbolizer, unwinder and pthread are potential source of mallocs. https://b.corp.google.com/issues/228110771 Reviewed By: kda Differential Revision: https://reviews.llvm.org/D123566
- Loading branch information
1 parent
08bd7d5
commit d3531fc
Showing
10 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
compiler-rt/test/sanitizer_common/TestCases/malloc_hook_skip.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %clangxx -O0 -g %s -o %t && %run %t | ||
|
||
// Test requires platform with thread local support with no dependency on malloc. | ||
// UNSUPPORTED: android | ||
// UNSUPPORTED: ios | ||
|
||
#include <assert.h> | ||
#include <sanitizer/allocator_interface.h> | ||
#include <sanitizer/coverage_interface.h> | ||
#include <stdlib.h> | ||
|
||
static int hooks; | ||
extern "C" { | ||
|
||
void __sanitizer_malloc_hook(const volatile void *ptr, size_t sz) { ++hooks; } | ||
|
||
void __sanitizer_free_hook(const volatile void *ptr) { ++hooks; } | ||
|
||
} // extern "C" | ||
|
||
void MallocHook(const volatile void *ptr, size_t sz) { ++hooks; } | ||
void FreeHook(const volatile void *ptr) { ++hooks; } | ||
|
||
int main() { | ||
int before; | ||
|
||
before = hooks; | ||
__sanitizer_print_stack_trace(); | ||
assert(before == hooks); | ||
|
||
__sanitizer_install_malloc_and_free_hooks(MallocHook, FreeHook); | ||
before = hooks; | ||
__sanitizer_print_stack_trace(); | ||
assert(before == hooks); | ||
|
||
return 0; | ||
} |