doctest icon indicating copy to clipboard operation
doctest copied to clipboard

endless loop with multiple `DOCTEST_SUBCASE`s when an exception is thrown prior to any subcase

Open jktjkt opened this issue 1 year ago • 2 comments

The following file causes an endless loop:

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>

TEST_CASE("wtf")
{
    static int cnt = 0;
    if (cnt++ >= 1) {
        throw std::runtime_error{"wat"};
    }
    DOCTEST_SUBCASE("1") {}
    DOCTEST_SUBCASE("2") {}
}

The expected behavior is that this simply reports an unexpected exception, and terminates cleanly.

  • doctest version: v2.4.11
  • Operating System: NixOS
  • Compiler+version: clang 16.0.1, GCC 12.2.0 (both produce the same results)

jktjkt avatar Jun 05 '23 23:06 jktjkt

I've bisected this to eb8b04a2b1db23ea5665cd8b5cbe859beb0ef80d, hence ccing @Saalvage .

We started getting this in a real codebase where some common, boring setup code started accidentally throwing an exception on its second run.

jktjkt avatar Jun 05 '23 23:06 jktjkt

I also experienced the same bug in the latest version! Please fix it!!!

LolloAAA avatar Feb 03 '24 21:02 LolloAAA