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

[bug] Crash in String Matcher #2931

Open
opmtk opened this issue Nov 13, 2024 · 0 comments
Open

[bug] Crash in String Matcher #2931

opmtk opened this issue Nov 13, 2024 · 0 comments

Comments

@opmtk
Copy link

opmtk commented Nov 13, 2024

Describe the bug

The following

        try {
            std::string a{ "string" };
            std::string const expected{ "string" };
            REQUIRE_THAT(a, Matches(expected));
        }
        catch (std::exception const& e) {
            std::cerr << std::format("caught '{}'\n", e.what());
        }

works as expected. If I get a bigger expected string (e.g. ~110kByte) it crashes with

...
[ctest] due to a fatal error condition:
[ctest]   SIGSEGV - Segmentation violation signal

The problem is related to the Matches matcher - the following doesn't crash:

        // Catch2's matchers haven't support for string_view
        std::string const expected_str{ csv_data::CsvSV };

        try {
            std::string a{ "string" };
            REQUIRE_THAT(expected_str, Matches(a));
        }
        catch (std::exception const& e) {
            std::cerr << std::format("caught '{}'\n", e.what());
        }

Expected behavior
I must not crash in that way, even I've a try/catch block/scope!

Reproduction steps

See above.

Platform information:

  • OS: Windows NT with devcontainer in VS Code running Ubuntu24.04
  • Compiler+version: gcc version 13.2.0 (Ubuntu 13.2.0-23ubuntu4)
  • Catch version: 3.4.0-1build1 amd64

Additional context

  • How can I ignore line endings with matchers? My reference data contains 16 rows with 161 columns in lines.
constexpr std::string_view const CsvSV =
R"(0,0.999994607194946,...
...
...,0.783392372240895
)";
  • How can a make a diff of the strings compared? E.g. only give the line number of difference?
@opmtk opmtk changed the title Crash in String Matcher [bug] Crash in String Matcher Nov 13, 2024
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