Repository navigation
Tests: dump a backtrace to stderr on a fatal signal in test mode - #1819
Merged
Merged
Conversation
When the command-line test runner crashes (e.g. a segfault in CI), the process's last stdio buffers are lost, so the log ends just before the crash with no indication of where it happened. Install handlers for SIGSEGV/SIGBUS/SIGABRT/SIGILL/SIGFPE (command-line test mode only, Apple/Linux; no-op on Windows) that write a native backtrace of the crashing thread straight to fd 2 - which also bypasses the app's std::cerr redirection into its logger - then restore the default disposition and re-raise, so the OS still writes its crash report and the exit code still reflects the crash. Also keep stdout line-buffered in test mode, so the test output reaches the log as it happens instead of being lost in the full buffer. An explicit 8192-byte buffer is used: with 0, MSVC's ucrt can end up with a zero-size buffer, which corrupts the next stdout write.
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up from the Mac Intel PaddleOCR crash investigation (#1811, #1812, #1817).
When the command-line test runner dies on a fatal signal, the CI log ends right before the crash — the process's last stdio buffers are lost, and on macOS the
.ipscrash report doesn't land in the log. This made the #1811 crash take multiple CI runs to pin down.What this adds (command-line test mode only, no GUI impact):
std::cerrredirection into its logger — then restore the default disposition and re-raise, so the OS still writes its crash report and the exit code (139) still reflects the crash. A re-entrancy guard makes a crash inside the handler just die immediately. No-op on Windows (no portable async-signal-safe backtrace API there; OS crash reports cover it).setvbuf(stdout, _IOLBF, 8192)in test mode so the test lines reach the log as they happen instead of being lost in the full pipe buffer. The explicit size matters: with 0, MSVC's ucrt ends up with a zero-size stdout buffer and the first write crashes with 0xC0000409 (hit this during the investigation).Proof it works: the #1817 A/B run used this handler to capture the backtrace that identified the Mac Intel crash root cause (a stack-use-after-return in the Qt socket tests, since fixed on main):