summaryrefslogtreecommitdiff
path: root/test/fuzzer/TraceMallocThreadedTest.cpp
blob: 0183d939af51b8eb3c5f498bc3ea123b34bfe91e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 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 <cstdlib>
#include <thread>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
  auto C = [&] {
    void * volatile 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;
}