Skip to content

Fix issue with duplicate signal entries in the list - #293

Merged
borrrden merged 4 commits into
masterfrom
crash_handling_enhance
May 26, 2026
Merged

Fix issue with duplicate signal entries in the list#293
borrrden merged 4 commits into
masterfrom
crash_handling_enhance

Conversation

@borrrden

Copy link
Copy Markdown
Member

SIGABRT and SIGIOT are the same signal on most platforms and this meant that the "previous" signal handler was getting registered correctly the first time, and then overwritten to the same function the second time causing an infinite loop. This adds a static assert to ensure that all signals in the list are unique. It also adds another test to make sure that other things that override the signal handler can still properly chain back.

SIGABRT and SIGIOT are the same signal on most platforms and this meant that the "previous" signal handler was getting registered correctly the first time, and then overwritten to the same function the second time causing an infinite loop.  This adds a static assert to ensure that all signals in the list are unique.  It also adds another test to make sure that other things that override the signal handler can still properly chain back.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an infinite-loop failure mode in the POSIX backtrace signal handler when the same signal value appears more than once in the handled-signal list (e.g., SIGABRT vs SIGIOT aliases). It adds compile-time validation of signal uniqueness and introduces a manual test to verify signal-handler chaining behavior when another handler overrides SIGSEGV.

Changes:

  • Add a static_assert to ensure the backtrace signal list contains no duplicate signal values.
  • Refactor the POSIX signal list into a constexpr std::array and adjust handler installation logic.
  • Update/add manual crash tests to exercise SIGABRT and an override+chain scenario for SIGSEGV.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
Tests/SupportTests.cc Updates the manual crash test to use raise(SIGABRT) and adds a new manual test that overrides SIGSEGV and attempts to chain back to the previous handler.
Fleece/Support/Backtrace+signals-posix.cc Adds compile-time uniqueness checking for the handled signals and refactors signal registration/default-action lookup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Fleece/Support/Backtrace+signals-posix.cc
Comment thread Fleece/Support/Backtrace+signals-posix.cc Outdated
Comment thread Fleece/Support/Backtrace+signals-posix.cc
Comment thread Tests/SupportTests.cc Outdated
Comment thread Tests/SupportTests.cc
Comment thread Tests/SupportTests.cc Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Fleece/Support/Backtrace+signals-posix.cc Outdated
Comment thread Tests/SupportTests.cc
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@pasin pasin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my understanding, the main point of this PR is to prevent a mistake to add a duplicate signals in the signals. Look good to me.

@borrrden
borrrden merged commit e93caf1 into master May 26, 2026
5 checks passed
@borrrden
borrrden deleted the crash_handling_enhance branch May 26, 2026 05:46
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

Successfully merging this pull request may close these issues.

3 participants