Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Tell cmake that Scudo is supported on Windows Tell cmake that Scudo is supported on Linux Tell MSVC that Scudo is supported Need to check that this works on Windows Change Windows allocator size to be 256GB Enable scudo on Windows properly Change literal type to avoid cl warning Auto-add scudo and scudo_cxx when using -sanitize=scudo to help testing. This is enough for the tests, though doesn't help as much with large programs like LLVM which drive the linker directly Use same format for adding libraries as asan above Avoid adding --gc-sections on Windows Avoid overriding computeHardwareCRC32 on Windows. This may cause lower performance on Windows, may need another way or providing this on Windows. Only enable builtins (actually required for scudo standalone) if compiler supports them Tests Rename getpagesize() to avoid naming conflict on Linux Move setting up signal handler later as this was firing on the malloc Remove stray change in SanitizerArgs.cpp Port threads test from pthreads to c++11 threads for portability as new test cxx_threads.cpp Moved mutex.lock() up before starting other threads or they may get the lock first. Change to mark as unsupported on windows, not just win32 Convert some more tests to unsupported on windows instead of win32 Mark tests as unsupported Test for minimal runtime unsupported on Windows Unsupported on Windows as relies on LD_LIBRARY_PATH. Or maybe could have parts of this running on Windows Mark dealloc-race.c as unsupported on Windows as requried fork() Clang format tests
- Loading branch information
Showing
27 changed files
with
282 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// RUN: %clangxx_scudo %s -o %t | ||
// RUN: %env_scudo_opts="QuarantineSizeKb=0:ThreadLocalQuarantineSizeKb=0" %run %t 5 1000000 2>&1 | ||
// RUN: %env_scudo_opts="QuarantineSizeKb=1024:ThreadLocalQuarantineSizeKb=64" %run %t 5 1000000 2>&1 | ||
|
||
// Tests parallel allocations and deallocations of memory chunks from a number | ||
// of concurrent threads, with and without quarantine. | ||
// This test passes if everything executes properly without crashing. | ||
|
||
#include <assert.h> | ||
#include <condition_variable> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <thread> | ||
|
||
#include <sanitizer/allocator_interface.h> | ||
|
||
int num_threads; | ||
int total_num_alloc; | ||
const int kMaxNumThreads = 500; | ||
std::thread thread[kMaxNumThreads]; | ||
|
||
std::condition_variable cond; | ||
std::mutex mutex; | ||
char go = 0; | ||
|
||
void *thread_fun(void *arg) { | ||
mutex.lock(); | ||
while (!go) { | ||
std::unique_lock<std::mutex> lk(mutex); | ||
cond.wait(lk); | ||
} | ||
|
||
mutex.unlock(); | ||
for (int i = 0; i < total_num_alloc / num_threads; i++) { | ||
void *p = malloc(10); | ||
__asm__ __volatile__("" | ||
: | ||
: "r"(p) | ||
: "memory"); | ||
free(p); | ||
} | ||
return 0; | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
assert(argc == 3); | ||
num_threads = atoi(argv[1]); | ||
assert(num_threads > 0); | ||
assert(num_threads <= kMaxNumThreads); | ||
total_num_alloc = atoi(argv[2]); | ||
assert(total_num_alloc > 0); | ||
|
||
printf("%d threads, %d allocations in each\n", num_threads, | ||
total_num_alloc / num_threads); | ||
fprintf(stderr, "Heap size before: %zd\n", __sanitizer_get_heap_size()); | ||
fprintf(stderr, "Allocated bytes before: %zd\n", | ||
__sanitizer_get_current_allocated_bytes()); | ||
|
||
mutex.lock(); | ||
for (int i = 0; i < num_threads; i++) | ||
thread[i] = std::thread(thread_fun, (void *)0); | ||
go = 1; | ||
cond.notify_all(); | ||
mutex.unlock(); | ||
for (int i = 0; i < num_threads; i++) | ||
thread[i].join(); | ||
|
||
fprintf(stderr, "Heap size after: %zd\n", __sanitizer_get_heap_size()); | ||
fprintf(stderr, "Allocated bytes after: %zd\n", | ||
__sanitizer_get_current_allocated_bytes()); | ||
|
||
return 0; | ||
} |
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
Oops, something went wrong.