Skip to content

test(libc): cover siginterrupt state boundaries - #9001

Open
Queuse wants to merge 3 commits into
boykopovar:mainfrom
Queuse:codex/test-siginterrupt-contracts
Open

Queuse wants to merge 3 commits into
boykopovar:mainfrom
Queuse:codex/test-siginterrupt-contracts

Conversation

@Queuse

@Queuse Queuse commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds a focused siginterrupt regression covering every signal-set word boundary, negative and extreme nonzero flags, repeated calls, successful errno preservation, unchanged neighboring bits, preservation of the installed handler/mask/other flags, later signal registrations, and invalid signal numbers with nonzero state sentinels. Compile-time checks cover the guest signal-set and sigaction layouts.

Stacks on #8872, which carries #8866; their implementations and authorship are retained. This contribution adds only the behavioral test and CMake registration. It does not change host-I/O interruption behavior.

Tested

Windows x86-64, WinLibs MinGW-w64 GCC 15.2.0, Release, full library build configuration, based on main 27c88a8 plus #8872/#8866.

  • Built libc, libkernel and the four focused test targets.
  • guest_signal_interrupt, guest_signals, guest_signal_sets and guest_sigtimedwait pass (4/4); the new test also passes after its final assertion update.
  • Mutation check: keeping SA_RESTART set on the nonzero-flag path makes the new test fail on disposition preservation. Restoring the implementation restores passing tests.
  • Conventions, whitespace and test-registration checks pass.
  • Linux, titles and PS5 hardware: not run. No claim of interrupting or restarting host-blocking I/O.

Required overlap scan completed. The #8866/#8872 overlap is the declared implementation stack; remaining source/debt matches belong to that stack or unrelated entries. Manual review of incomplete comparisons found no duplicate of the new regression. Current overlap review against main a6dcea9279: #9123 appends pending-signal tests at the same end of GuestSignals.cpp; both blocks must be preserved in either merge order. Its pending-signal behavior is independent of this test. #7622 overlaps the include insertion in Process.cpp, and the remaining confirmed matches edit other libc debt entries. #6044 reorganizes test registration and would require adapting this registration if it lands first. The carried production implementations still match #8866/#8872. Integration into the consulted main is clean; tests above remain on their stated base.

Merge order: #8866 → #9499 → #8872 → #9001, following the proposal in the merge-order comment. #9499 is still open. A trial merge of this head (630daf82ec) with #9499 (56b2a6393f) confirms conflicts in Signals.cpp and docs/dev/debt/libkernel.md. When rebasing after #9499 lands, preserve SettleReset(guest) together with the _sigintr-dependent flags in signal_nid_postfix, both load-time registrations (RegisterSigaction_nid_no_patch and GuestSigprocmaskRegister_nid_no_patch), and both applicable debt entries. The combined code has not been built or tested; rerun the focused signal tests after that rebase.

Checklist

ycbuzi and others added 3 commits October 21, 2026 05:55
The public SDK's libkernel, libkernel_sys and libkernel_web stub tables declare _sigintr, the
sigset_t that FreeBSD's libc shares between signal and siginterrupt, and no built library
provided it (boykopovar#8846). libkernel now exports the 16-byte object, zero at start, and signal records
a handler with SA_RESTART unless its signal is in the set, as lib/libc/gen/signal.c does.

siginterrupt, which fills the set, is a libSceLibcInternal export; libc does not link libkernel
and cannot reach the dispositions, so it stays out and a debt entry for signal says so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…gisters

siginterrupt is a libSceLibcInternal export (the public SDK's stub table has it there, not in the
kernel tables) and FreeBSD 11.4's lib/libc/gen/siginterrupt.c reads the signal's disposition,
sets or clears the signal's bit in _sigintr and SA_RESTART, and installs the disposition again.
libc cannot call libkernel, so, as the pthread hooks do, libc keeps a registered sigaction and
the address of the _sigintr set, and libkernel registers both from a static initializer when it
loads. A call before that throws; the set is written without libkernel's registration lock, as
FreeBSD's libc does. Builds on boykopovar#8866, which adds the set.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Progress report (27c88a8 → 630daf8)

📈 System libraries: 51.03% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc siginterrupt_nid_postfix

@clairtonmichel

Copy link
Copy Markdown

Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5):

  • Built cleanly with zero errors.
  • Ran the complete libc signal and state boundary test suite (guest_signal_interrupt, guest_signals, guest_sigtimedwait, guest_sigaltstack, guest_host_libc, etc.): 100% passed successfully (15/15 green in 2.28s).
  • siginterrupt state boundaries coverage behaves correctly on host. Ready to merge!

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6565 docs/dev/debt/libc.md L136
PR 7622 core/libs/prx/libc/src/Process.cpp L1
PR 8880 docs/dev/debt/libc.md L136
PR 9123 core/libs/tests/GuestSignals.cpp L400
PR 9133 docs/dev/debt/libc.md L136
PR 9170 docs/dev/debt/libc.md L136
PR 9447 docs/dev/debt/libc.md L136
PR 9526 docs/dev/debt/libc.md L136
PR 9527 docs/dev/debt/libc.md L136

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3965 docs/dev/debt/libc.md
PR 3986 core/libs/prx/libkernel/System/src/Signals.cpp
core/libs/tests/GuestSignals.cpp
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 5303 docs/dev/debt/libc.md
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
core/libs/tests/GuestSignals.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6830 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6879 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7081 docs/dev/debt/libc.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Signals.cpp
PR 7509 docs/dev/debt/libkernel.md
PR 7565 docs/dev/debt/libkernel.md
PR 7648 docs/dev/debt/libc.md
PR 7653 docs/dev/debt/libkernel.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8547 docs/dev/debt/libkernel.md
PR 8553 docs/dev/debt/libkernel.md
PR 8726 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 8906 docs/dev/debt/libkernel.md
PR 8965 docs/dev/debt/libc.md
PR 9363 docs/dev/debt/libkernel.md
PR 9408 docs/dev/debt/libc.md

@EagleBearerYS

Copy link
Copy Markdown
Contributor

@Queuse a merge-order note: this PR carries #8866's and #8872's commits, and #9499 changes Signals.cpp next to both: a SettleReset(guest) call in signal_nid_postfix, and a load-time registration of sigprocmask with libc at the end of the file. Both sides' lines stay. #9499 goes after #8866 and proposes going before #8872 and this PR, which would rebase over it. If you'd rather, say so and #9499 will list them under Depends on.

@Queuse

Queuse commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@EagleBearerYS That order works for me: #8866 → #9499 → #8872 → this PR. I've added #9499 to the dependencies here. Once it lands, I'll rebase, keep SettleReset(guest) alongside the _sigintr check and preserve both load-time registrations, then rerun the focused signal tests. Thanks for checking the overlap.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants