catchorg / catchorg/Catch2

REQUIRE Heisenbug

Open
#1,004 8 comments 0 reactions 0 assignees View on GitHub
Possible bug
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

I'm getting a particularly nasty Heisenbug under Catch 1.3.1, and it seems to relate to REQUIRE. Updating to 1.10 fixes it, but because it's a Heisenbug, I can't be sure if it is really fixed or not. I've read the changelog and I can't find anything that looks like a fix for this... so I'd be grateful if you could let me know if there are any known issues here.
______________________________________

It causes SIGABRT, SIGSEGV, SIGILL or bad_alloc, all of which suggest memory corruption. It is reproducible in the sense that running exactly the same code produces exactly the same results, but any of the following can stop the bug from happening (or change which error occurs):

-- Removing source files containing tests that are not being run
-- moving the (inline) function in question from one file to another
-- copying the function, giving it a fresh name and calling the copy

This makes it hard to give a self-contained minimal example, but the problem definitely occurs in this code:

REQUIRE(true == true);
REQUIRE(879.9 == Approx(876.5).epsilon(0.0000001));

Both REQUIREs are needed to trigger the bug.

(The actual numbers are arbitrary.) It's only reproducible using clang on release mode; debuggers, even using release build with deb. symbols, don't find it. I'm testing on Windows 10/Cygwin 2.8.2.

Edit: Could this issue relate to the lifetime of the `Approx` object? I don't know how REQUIRE is expanded, but is is possible that the `Approx` is not being kept alive for long enough?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.