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

create_xml_reporter() crashes on MSYS platform #309

Open
tpecar opened this issue Nov 8, 2022 · 2 comments
Open

create_xml_reporter() crashes on MSYS platform #309

tpecar opened this issue Nov 8, 2022 · 2 comments

Comments

@tpecar
Copy link

tpecar commented Nov 8, 2022

The bug originates at the tmpfile() function, which returns NULL.

child_output_tmpfile = tmpfile();

The result isn't checked, and first usage causes segmentation fault.

I'm doing a standard build within a MSYS2 environment.

Minimal example which invokes this

#include <cgreen/cgreen.h>
#include <cgreen/mocks.h>
#include <cgreen/xml_reporter.h>

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

Ensure(these_should_be_true) {
    assert_true(1);
}

TestSuite *assertion_tests() {
    TestSuite *suite = create_test_suite();
    add_test(suite, these_should_be_true);
    return suite;
}


int main(int argc, char **argv) {
    TestSuite *suite = create_test_suite();
    add_suite(suite, assertion_tests());

    /* XML reporter */
    TestReporter *reporter = create_xml_reporter("out");

    return run_test_suite(suite, reporter);
}

Note that crashes under MSYS silently exit the program with exit code 0. This also happens under debug (actually, it also terminates gdb).

Debugging the application under mingw gdb properly catches the SIGSEGV signal.

@tpecar
Copy link
Author

tpecar commented Nov 8, 2022

To be more specific, it crashes while running the test, so within the run_test_suite() call, but this is due to failing to open a tmpfile in create_xml_reporter()

@thoni56
Copy link
Contributor

thoni56 commented Jan 25, 2023

I can't reproduce this under MSYS2/NT, but the example does crash under MSYS2/MinGW (both 32 and 64). Which one were you running?

We do not have an official list of supported platforms it seems, but I know I at some point struggled with the MSYS2:s and could not figure out how to make Cgreen work on the MinGW-versions. AFAIK the MSYS2/NT is Cygwin-based, which is a "Unix Emulation", which makes it more straight forward to compile *nix programs on a Windows box.

I'm not familiar enough with the MinGW environment to understand why tmpfile() would fail and what to do then. (Sure an error message would be slightly better than a crash, but it would not make Cgreen run on MinGW...).

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

2 participants