Skip to content
New issue

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

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

Already on GitHub? # to your account

": " in long test case description leads to segmentation fault when tests fail #2309

Closed
KKoovalsky opened this issue Oct 20, 2021 · 2 comments
Labels

Comments

@KKoovalsky
Copy link

Describe the bug

Test case description, which contains ": " (colon + space) somewhere at the end of the description, leads to segmentation fault, when the tests fail.

TEST_CASE("Measurements are scheduled for collecting and publishing. According to requirements: OP",
          "[measurement_scheduler]")

Expected behavior

No segmentation fault shall occur when the tests fail.

Reproduction steps

  1. Provide Catch2, using CMake integration guide; using FetchContent module.
  2. Create such file:
#include <catch2/catch_test_macros.hpp>
TEST_CASE("Measurements are scheduled for collecting and publishing. According to requirements: OP",
          "[measurement_scheduler]")
{
    REQUIRE(false);
}
  1. Compile, run and see output:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aura_host_tests is a Catch v3.0.0-preview.3 host application.
Run with -? for options

Randomness seeded to: 523709168

-------------------------------------------------------------------------------
Measurements are scheduled for collecting and publishing. According to
                                                                                     requirements: OP
                                                                                     According to requirements: OP
                                                                                     publishing. According to requirements: OP
                                                                                     collecting and publishing. According to requirements: OP
                                                                                     scheduled for collecting and publishing. According to requirements: OP-------------------------------------------------------------------------------
Measurements are scheduled for collecting and publishing. According to
                                                                                     requirements: OP
                                                                                     According to requirements: OP
                                                                                     publishing. According to requirements: OP
                                                                                     collecting and publishing. According to requirements: OP
                                                                                     scheduled for collecting and publishing. According to requirements: OP-------------------------------------------------------------------------------
Measurements are scheduled for collecting and publishing. According to
                                                                                     requirements: OP
                                                                                     According to requirements: OP
                                                                                     publishing. According to requirements: OP
                                                                                     collecting and publishing. According to requirements: OP
                                                                                     scheduled for collecting and publishing. According to requirements: OPterminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::append: __pos (which is 18446744073709551600) > this->size() (which is 87)
-------------------------------------------------------------------------------
Measurements are scheduled for collecting and publishing. According to
                                                                                     requirements: OP
                                                                                     According to requirements: OP
                                                                                     publishing. According to requirements: OP
                                                                                     collecting and publishing. According to requirements: OP
                                                                                     scheduled for collecting and publishing. According to requirements: OPterminate called recursively
Aborted (core dumped)

I attach the valgrind dump as well: error.log.

Platform information:

  • OS: Ubuntu 20.04.2
  • Compiler+version: GCC v9.3.0 or Clang v13.0.0
  • Catch version: v3.0.0-preview3 or efd8cc8777406457a34e15313076ac3a77d4e54b.

Additional context

What works without segmentation fault error (works as expected):

TEST_CASE("Measurements are scheduled for collecting and publishing. According to requirements [OP]", ...
TEST_CASE("Measurements are scheduled for collecting and publishing. According to requirements:OP", ...
TEST_CASE("Measurements are scheduled for collecting and publishing. According to requirements:OP", ...
TEST_CASE("Measurements are scheduled for collecting and publishing. According to requ: OP", ...
TEST_CASE(": ", ...

What doesn't work:

TEST_CASE("Measurements are scheduled for collecting and publishing. According to requi: OP", ...
@horenmar horenmar added the Bug label Oct 22, 2021
@horenmar
Copy link
Member

Okay, I see the problem. Console reporter is trying to be fancy and make it so that when there is ": " in the test name, then to change how the text is line broken like this:

Check this out: 
                fancy linebreaking!

instead of just this

Check this out:
fancy linebreaking?

However, the test name you have is long enough that it suddenly asks for line breaks to happen past the allowed line width and then all hell breaks loose. This can be fixed easily enough by clamping the computed indentation value, but that can still lead to some pathological behaviour, e.g. like this:

Check this out:
                f
                a
                n
                c
                y
                
                l
                i
                .
                .
                .

if the break falls just on the edge of the output width.

@KKoovalsky
Copy link
Author

Can we remove the feature related to fancy line breaking?

KKoovalsky added a commit to KKoovalsky/AuraFW that referenced this issue Oct 25, 2021
When the tests failed Catch2 had a segmentation fault. This was related
to the TEST_CASE description.

I have created an issue in Catch2, see:
catchorg/Catch2#2309
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants