1 // This file is distributed under the University of Illinois Open Source
2 // License. See LICENSE.TXT for details.
3 
4 // Check that allocation tracing from different threads does not cause
5 // interleaving of stack traces.
6 #include <assert.h>
7 #include <cstddef>
8 #include <cstdint>
9 #include <cstring>
10 #include <thread>
11 
12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
13   auto C = [&] {
14     volatile void *a = malloc(5639);
15     free((void *)a);
16   };
17   std::thread T[] = {std::thread(C), std::thread(C), std::thread(C),
18                      std::thread(C), std::thread(C), std::thread(C)};
19   for (auto &X : T)
20     X.join();
21   return 0;
22 }
23