Skip to content

fix(libkernel): report the sender in the si_code of sigwaitinfo and sigtimedwait - #8497

Open
xXPBSXx wants to merge 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/siginfo-sender-code
Open

xXPBSXx wants to merge 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/siginfo-sender-code

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What

The guest queue of pending signals kept only a bit per signal, and FillSiginfo always wrote si_code 0 (and the caller's pid). FreeBSD 11.4 stamps the signal with the sender: kill with SI_USER (0x10001, sys/kern/kern_sig.c:1788), thr_kill (so raise and pthread_kill) with SI_LWP (0x10007, kern_thr.c:401, lib/libc/gen/raise.c:52), and the interval-timer expiry with SI_KERNEL (0x10006) and pid 0 (kern_time.c:899, kern_sig.c:2087). Each pending signal now stores its code when it is marked, and sigwaitinfo/sigtimedwait return it. The expectations in guest_sigtimedwait that pinned 0 change accordingly.
Fixes #8496
The expectations of guest_sigtimedwait that #4138 set to 0 change here; #4138 took the siginfo_t layout from FreeBSD 11 and did not measure si_code on a console, as far as its description says. Overlap: #7192 (open) touches Signals.cpp and the siginfo fill; git merge-tree is clean for it and for #8407, #8411, #8414 and #8467, and has conflicts with #3986 (3), #6044 (26) and #7201 (25). pr_overlap was not run.

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main cabd80f + this commit:

  • guest_sigtimedwait: Exit code 0xc0000409 with System/src/Signals.cpp taken back to main (new expectations kept), passes with the change (3 of 3 runs). Cases: raise and pthread_kill from another thread give si_code 0x10007; kill(getpid(), SIGINT) gives 0x10001 with the caller's pid; a blocked SIGALRM from alarm(1) gives 0x10006 and pid 0.
  • guest_signals, guest_itimer, guest_itimer_pending_default, guest_kill, guest_signal_sets, guest_sigaltstack, guest_getitimer pass.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux (shared code, not built there), a console (values come from the FreeBSD source, not measured), a title run; no title is known to read si_code. Signals that arrive asynchronously from the host keep SI_LWP.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…igtimedwait

FreeBSD 11.4 stamps the queued signal with the sender: kill() uses SI_USER
0x10001 (sys/kern/kern_sig.c:1788), thr_kill, and so raise and pthread_kill,
use SI_LWP 0x10007 (kern_thr.c:401, lib/libc/gen/raise.c:52), and the
SIGALRM expiry of an interval timer comes from kern_psignal with SI_KERNEL
0x10006 and pid 0 (kern_time.c:899, kern_sig.c:2087; values in
sys/sys/signal.h:400-409). The guest reported si_code 0 for all of them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the fix error Closes an issue (Fixes #N) label Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

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 3986 core/libs/prx/libkernel/System/src/Signals.cpp
PR 6044 core/libs/tests/GuestSigtimedwait.cpp
PR 7201 core/libs/prx/libkernel/System/src/Signals.cpp
PR 7622 core/libs/prx/libkernel/System/src/Signals.cpp

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

Labels

fix error Closes an issue (Fixes #N) libkernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libkernel: sigwaitinfo and sigtimedwait report si_code 0 for every signal; FreeBSD 11.4 reports the sender

2 participants