#2864·Catch2

Memory leak when using exit()

Author: itacud95Created Apr 29, 2024Updated Jul 12, 2026

Describe the bug I noticed valgrind reports a leak when using exit(0) in a test case.

Expected behavior I would expect it not to leak.

Reproduction steps

TEST_CASE("fork") {
    pid_t pid = fork();
    REQUIRE(pid != -1);
    if (pid == 0) {
        exit(0);
    } else {
        int status;
        waitpid(pid, &status, 0);
    }
    CHECK(true);
}
// valgrind --leak-check=full ./binary

Platform information:

  • OS: linux
  • Compiler+version: g++ (GCC) 13.2.1 20230801
  • Catch version: v3.5.3

Additional context valgrind version: 3.22