brintos

brintos / llvm-project-archived public Read only

0
0
Text · 628 B · 2158c8a Raw
28 lines · cpp
1// Test that leaks detected after forking without exec().2// RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s3 4/// Fails on clang-cmake-aarch64-full (glibc 2.27-3ubuntu1.4).5// UNSUPPORTED: target=aarch64{{.*}}6 7#include <assert.h>8#include <stdlib.h>9#include <sys/wait.h>10#include <unistd.h>11 12int main() {13  pid_t pid = fork();14  assert(pid >= 0);15  if (pid > 0) {16    int status = 0;17    waitpid(pid, &status, 0);18    assert(WIFEXITED(status));19    return WEXITSTATUS(status);20  } else {21    for (int i = 0; i < 10; ++i)22      malloc(1337);23    // CHECK: LeakSanitizer: detected memory leaks24  }25  return 0;26}27 28