Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining subcases and threads can put doctest into an infinite loop #803

Open
patstew opened this issue Sep 7, 2023 · 0 comments
Open

Comments

@patstew
Copy link
Contributor

patstew commented Sep 7, 2023

TEST_CASE("crash") {
    SUBCASE("sub") { CHECK(true); }
    std::jthread([] { REQUIRE(false); });
};

This test case causes doctest to try and print out its subcase stack 2^64-1 times. The same thing happens with any exception, segfault etc in the sub thread, not just REQUIRE. The problem is that reportFault calls subcase_end according to the max stack depth, not the current stack location, so currentSubcaseLevel gets decremented below 0. Then the logTestStart attempts to print that many names from the subcase stack, with sad results.

patstew added a commit to patstew/doctest that referenced this issue Sep 7, 2023
patstew added a commit to patstew/doctest that referenced this issue Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant