diff options
author | Vitaly Buka <vitalybuka@google.com> | 2017-10-31 20:49:48 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2017-10-31 20:49:48 +0000 |
commit | 58da33e35ccdb19cf789ba0cd9b5c021a0f9f43a (patch) | |
tree | 8207e4c8b70ed70629b7b04d226ac12c21890a17 /compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp | |
parent | f87c142d9e19795596681b7f18bbaf8380cd41b7 (diff) | |
download | bcm5719-llvm-58da33e35ccdb19cf789ba0cd9b5c021a0f9f43a.tar.gz bcm5719-llvm-58da33e35ccdb19cf789ba0cd9b5c021a0f9f43a.zip |
[fuzzer] Fix threaded stack printing and nested mallocs
Summary: Nested mallocs are possible with internal symbolizer.
Reviewers: kcc
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D39397
llvm-svn: 317034
Diffstat (limited to 'compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp')
-rw-r--r-- | compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp b/compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp new file mode 100644 index 00000000000..5603af344cb --- /dev/null +++ b/compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp @@ -0,0 +1,22 @@ +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. + +// Check that allocation tracing from different threads does not cause +// interleaving of stack traces. +#include <assert.h> +#include <cstddef> +#include <cstdint> +#include <cstring> +#include <thread> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + auto C = [&] { + volatile void *a = malloc(5639); + free((void *)a); + }; + std::thread T[] = {std::thread(C), std::thread(C), std::thread(C), + std::thread(C), std::thread(C), std::thread(C)}; + for (auto &X : T) + X.join(); + return 0; +} |