libkernel: blocked signal masks are shared between threads instead of inherited per thread #2879
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-10T17:21:10Z.
Maintenance status, 7 November 2026
Resolved upstream: #3986 is merged and this issue is closed. Its submitted head
694b2b470440bbd3d8764bd742c7496a2f81921dsupplied per-thread blocked masks/handler holds and creator-mask inheritance while preserving main's process-wide pending-signal model. The earlier “keep open” status is superseded.The original probe below is historical evidence at its named source pin, not a current-main failure. This sweep verified the merge/closure and source scope; it did not rerun the signal suite. Host-delivery limitations remain as documented by the merged change.
AI-assisted report maintenance: yes.
Original reproduction on the pinned main below
Windows 11 Enterprise build 26200, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja Release. Full system libraries built from main
57f96fd2b36563e8380c603a92b1ef0d9d3a6aa4, without PR2754 or any local signal changes.A standalone probe calls the existing
sigprocmaskNIDaPcyptbOiZsin the built library. It uses actual guestpthread_create/pthread_join. Five separate processes produced the same failures:0x40000x2bits[2] == 1bits[2] == 00x00010100Child inheritance appeared to pass, but the mask is global, so this is not evidence of proper inheritance.
The global/32-bit limitations are already documented in technical debt. This report adds a reproducible behavioral check, including lost pending delivery and unblockable-signal readback. It is not a regression introduced by the proposed
pthread_sigmaskadapter.The expected model follows FreeBSD 11's kern_sigprocmask (thread mask,
SIG_CANTMASK, pending notification on unblock) and sigset_t, plus the POSIX pthread_sigmask contract. No console behavior was measured.Existing work and verification
Zaid-Talib's separate guest-signal-masks branch already contains broader mask work. PR1431's current diff does not contain that mask work. With the separate branch combined locally with the pinned main, preserving main's Windows AVX restoration and retry logic, the same five checks pass. Relevant Windows tests (signals, exception delivery, thread identity, stacks, CPU clocks, cancellation and nested sleeps) each passed five repetitions. Combined exception test runs were 15.95–16.08 s. Linux and the full CTest suite were not run.
No PR or branch was published. Suggested direction: validate the existing per-thread/pending-signal work rather than treating a new export alone as complete signal-mask support.
Standalone Windows probe
Build full libraries with
BUILD_TESTING=ON, save the source below asmask_probe.cppoutside the repository, then use the same MinGW toolchain:The toolchain runtime DLL directory must be on PATH. The argument is the patched library directory, not
unpatched. Exit 1 reports behavioral failure; loader/probe errors use different exit codes. The probe restores its mask and handler before exiting.Probe source
AI-assisted: OpenAI Codex assisted with investigation, the probe, local integration and this report. No game files are included, and no game execution or compatibility is claimed by this probe.
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T17:21:40Z.
@Amoenus thanks for the probe and the table, it made this easy to pin down. Fix branch:
Silverash-i8/AnyPS5-fork:fix/per-thread-signal-mask(43b1020a, one commit onmaina11c8f7f).Following FreeBSD's
kern_sigprocmask,Signals.cppnow keeps a blocked and a pending set per guest thread instead of the one process-wide 32-bit mask. Against your four checks:scePthreadCreatestarts the new thread with its creator's mask, so a child changing its mask leaves the parent's alone.0x00010100.raise(and sokillandpthread_killto self) of a blocked signal is kept pending and delivered beforesigprocmaskreturns from the unblock. A signal whose disposition is ignore is discarded instead of kept.guest_signalsgains these checks: the child thread inheriting0x4000, changing to0x2and the parent still reading0x4000after the join, a full-width round trip, the SIGKILL/SIGSTOP bits dropped, the deferred handler running on unblock, and an ignored blocked signal not running a handler later.Windows 11 Home 26200, WinLibs GCC 15.2.0 r7, Release:
guest_signals,guest_signal_sets,guest_user_contextandguest_user_context_exitpass 5 of 5 (--repeat until-fail:5). Thesigsetjmp/siglongjmpandgetcontext/setcontextpaths go through_sigprocmask, so those last three cover them.guest_signalsagainstmain'sSignals.cppandThread.cppaborts, so it catches the old behaviour.ctest -R '^guest_'(-j8): 288 of 290. The two failures are onmaintoo:guest_filesystem(#3518) andguest_kernel_sys(#3510).windows_exceptionsfails, as onmain(#3411).check_conventions.py --base upstream/mainpasses.Linux (WSL2 Ubuntu 22.04, kernel 6.18.33.2-microsoft-standard-WSL2, glibc 2.35, GCC 13.4.0, Release):
main'sSignals.cppandThread.cppthe newguest_signalsaborts here too (checked in a GCC 11.4 build of the same tree, which buildslibkerneland its tests).ctest -R '^guest_'(-j4): 269 of 270. The failure isguest_kernel_stack_protect, which fails the same way withmain'sSignals.cppandThread.cpp; it's #3459 (GCC 13 onmain), not this change.pr_overlap_encodingusessubprocess._text_encoding, which WSL's Python 3.10 doesn't have, andlinux_executable_exportsstops compiling its own C probe (RTLD_DEFAULTundeclared), so neither reaches AnyPS5 code.One limitation stays, and I replaced the TechnicalDebt entry with it: a host signal from outside the guest (Ctrl+C, or
SIGTERMfrom another process) is checked against the mask of whichever host thread receives it and stays pending on that thread, where FreeBSD would hand it to a thread that doesn't block it.My one open PR slot is in use (#3518), so I can't open this myself. Anyone eligible is welcome to carry it with the commit as it is. A run on native Linux, rather than WSL, would still be welcome.
AI-assisted (Claude Code); I ran the above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T20:39:42Z.
Now that my first PR has merged I can open this myself: #3986, the same change rebased onto
main0a8b1d32, with Windows (540 of 540 non-GPU tests) and WSL Linux runs in its description.AI-assisted (Claude Code).