Repository navigation
How does gtest handle segmentation violations in its own code? #5112
|
All my gtest-based test programs are crashing with a segmentation violation (error code 139) after the test suite successfully completes and after successfully listing the tests. This is with 1.18.0 (other versions not tested) and only when compiled with gcc (version 13.2/MinGW 13.2; other versions not tested) on an x86_64 processor. On an arm64 processor or when compiled with MSVC or ClangCL the problem does not occur. I have been trying without success to capture a crash dump on the failing CI because I do not have an x86_64 computer on which to reproduce the problem locally. I even tried procdump which reports that the process exited with code 0 yet the CI still reports a failure. This leads to the question does gtest catch segmentation violation exceptions and handle them itself so Windows does not see them? If so, how can I get a crashdump or stack trace? |
Replies: 6 comments
|
On x86_64 MinGW/gcc, if the crash happens after RUN_ALL_TESTS returns, it can be related to teardown/global destructors. gtest itself doesn't catch segfaults by default; on Windows with SEH you could wrap, but with POSIX signals you'd need a handler. For debugging CI: try running with |
|
gtest doesn't catch SEGVs/signals by default. On Windows, SEH exceptions differ; on POSIX, unhandled signals terminate the process. After RUN_ALL_TESTS returns, crashes often come from static/global destructor order (including DLL teardown on MinGW/x86_64). Try |
|
gtest doesn't catch SEGVs/signals by default. On POSIX, unhandled signals (like SIGSEGV) terminate the process immediately. On Windows, crashes are SEH exceptions — gtest's The post-RUN_ALL_TESTS crash on x86_64 MinGW/gcc is common due to global/static destructor order, including DLL teardown. If destructors access already-unloaded libs or depend on order, you get faults at process exit. Quick fixes for CI:
If you share a stack trace, it's easier to pinpoint the exact destructor. But based on "after successful test run on MinGW x86_64", teardown ordering is the likely culprit. |
|
@5h4d0wn1k, thank you for your advice. I already have WER local dump rules set up but am not getting any crash dumps, hence this thread. I tried I will try coredumpctl as soon as I have time.
That is what I am struggling to obtain and why I need a crashdump.
The two statements on each side of the ellipsis seem to conflict. What is this gtest wrapper and how does it mask exit? Is there documentation? |
|
Before I could try Note that when building gtest as a dll I was setting Thanks again to @5h4d0wn1k for your help. |
|
The answer to the question I posed is "gtest doesn't catch SEGVs/signals by default." - @5h4d0wn1k. |
The answer to the question I posed is
"gtest doesn't catch SEGVs/signals by default." - @5h4d0wn1k.