Memory leak when using exit()

Open
#2,864 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
cpp, linux

Research direction

Start by running the provided fork test case under Valgrind with --leak-check=full, focusing on the child path that calls exit(0) and the parent path that calls waitpid. Trace the framework's exit handling to identify the allocation reported as leaked. Done means the reproduction no longer reports a leak while the test still completes successfully.

Written by the indexing model from the issue text.

Description

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

Dominant language
C++
Stars
21.6k
Forks
3.4k
Avg merge
3d 12h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from catchorg/Catch2

All issues in catchorg/Catch2

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.