snitch-org / snitch

Lightweight C++20 testing framework.
Boost Software License 1.0
264 stars 10 forks source link

clang windows segfault #195

Open adamdusty opened 5 days ago

adamdusty commented 5 days ago

Getting a segfault with a minimal test setup on windows with clang 19. Same code compiles and runs with g++ 14.2.

>clang++ --version
clang version 19.1.1
Target: x86_64-w64-windows-gnu
Thread model: posix

Minimal example

#include <snitch/snitch.hpp>

TEST_CASE("Hello world", "[tag]") {
    CHECK(1 == 1);
}

LLDB output and backtrace

* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ff71a86764c: Access violation reading location 0x19ef1883c08
    frame #0: 0x00007ff71a86764c tests.exe`snitch::impl::try_get_current_test() at snitch_test_data.cpp:22:12
   19   }
   20  
   21   test_state* try_get_current_test() noexcept {
-> 22       return thread_current_test;
   23   }
   24
   25   void set_current_test(test_state* current) noexcept {
(lldb) bt
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ff71a86764c: Access violation reading location 0x19ef1883c08
  * frame #0: 0x00007ff71a86764c tests.exe`snitch::impl::try_get_current_test() at snitch_test_data.cpp:22:12
    frame #1: 0x00007ff71a8670c8 tests.exe`snitch::registry::run(this=0x00007ff71a89f040, test=0x00007ff71a89f040) at snitch_registry.cpp:500:38
    frame #2: 0x00007ff71a8678b8 tests.exe`snitch::registry::run_selected_tests(this=0x00007ff71a89f040, run_name=(_M_len = 13, _M_str = "tests.exe"), 
filter_strings=0x0000001d459eb520, predicate=0x0000001d459eb508) at snitch_registry.cpp:618:22
    frame #3: 0x00007ff71a867c02 tests.exe`snitch::registry::run_tests(this=0x00007ff71a89f040, run_name=(_M_len = 13, _M_str = "tests.exe")) at snitch_registry.cpp:695:12
    frame #4: 0x00007ff71a8680f0 tests.exe`snitch::(anonymous namespace)::run_tests_impl(r=0x00007ff71a89f040, args=0x0000001d459efdc0) at snitch_registry.cpp:780:22
    frame #5: 0x00007ff71a864f72 tests.exe`snitch::registry::run_tests(this=0x00007ff71a89f040, args=0x0000001d459efdc0) at snitch_registry.cpp:788:26
    frame #6: 0x00007ff71a86493f tests.exe`main(argc=1, argv=0x0000019f17029a80) at snitch_main.cpp:13:26
    frame #7: 0x00007ff71a861340 tests.exe`__tmainCRTStartup + 492
    frame #8: 0x00007ff71a861146 tests.exe`.l_start + 18
    frame #9: 0x00007ffdea747374 kernel32.dll`BaseThreadInitThunk + 20
    frame #10: 0x00007ffdeb3fcc91 ntdll.dll`RtlUserThreadStart + 33
cschreib commented 2 days ago

I am unable to reproduce so far, but I have only tested clang-16. While I try with clang-19, would you mind posting the content of snitch_config.hpp?

cschreib commented 2 days ago

I tried clang-19 (the exact same version as you) on Windows and still running OK. I think I'm going to need more info:

Another possibility is that you are using a different set of build options between the compiled snitch library and your test application. This shouldn't happen in normal use, but perhaps there's an issue with your build setup.