Skip to content

feat(libkernel_sys): implement sigqueue - #9389

Open
GitamarT045T3R wants to merge 3 commits into
boykopovar:mainfrom
GitamarT045T3R:feat/libkernel_sys-sigqueue
Open

GitamarT045T3R wants to merge 3 commits into
boykopovar:mainfrom
GitamarT045T3R:feat/libkernel_sys-sigqueue

Conversation

@GitamarT045T3R

Copy link
Copy Markdown
Contributor

What

sigqueue in libkernel_sys was a NotImplemented stub. It now follows FreeBSD 11's sys_sigqueue:

Case FreeBSD 11 Now
signal above 128 (_SIG_MAXSIG), or negative EINVAL EINVAL
pid 0 or below EINVAL: only a single process EINVAL
a pid that is not the guest pfind fails, ESRCH ESRCH
signal 0 checks only returns 0, sends nothing
the guest's own pid pksignal with SI_QUEUE and the value libkernel's raise, so ignored, blocked, default and handled signals behave as they do for kill

The signal check comes before the pid check, as in FreeBSD.

Gaps, in a new libkernel_sys debt entry: the value is dropped. libkernel delivers signals without siginfo, so si_code and si_value are not set and an SA_SIGINFO handler throws, as it does for raise. The limit of 128 pending queued signals per process (EAGAIN) is not modelled.

Tested

Windows 10 Pro 22H2 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release, BUILD_TESTING=ON, on main cecb540a6:

  • New guest_sigqueue covers:
    • signal 0 to the guest, with and without a value, succeeds and leaves errno alone;
    • EINVAL for signals -1 and 129 to any pid, and for pids 0, -1 and the negated guest pid;
    • ESRCH for other pids, including with signal 0;
    • an ignored signal is not delivered;
    • a handled signal reaches its handler before sigqueue returns;
    • a failed call delivers nothing.
  • On main the first call throws sigqueue_nid_postfix not implemented.
  • guest_kill and guest_kernel_sys still pass.
  • python tools/check_conventions.py --base origin/main passes.
  • Not built or run on Linux or macOS. The code has no host-specific paths: it goes through libkernel's getpid and raise.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Progress report (4777cac → 3a75bf4)

📈 System libraries: 43.25% (+0.02%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel sigqueue_nid_disambig1_nid_postfix
libkernel_sys sigqueue_nid_postfix

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Exports with a name or library/NID already present in main:

  • sigqueue (also exported by another library in main: core/libs/prx/libkernel_sys; may be intentional)
    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 4563 core/libs/prx/libkernel/CMakeLists.txt
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.cpp
docs/dev/debt/libkernel.md
PR 6149 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7156 core/libs/prx/libkernel/CMakeLists.txt
PR 7192 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7532 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7565 docs/dev/debt/libkernel.md
PR 7622 core/libs/prx/libkernel/System/src/Signals.cpp
PR 7645 core/libs/prx/libkernel/CMakeLists.txt
PR 7804 docs/dev/debt/libkernel.md
PR 8041 core/libs/prx/libkernel/CMakeLists.txt
PR 8463 core/libs/prx/libkernel/CMakeLists.txt
PR 8497 core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 8605 docs/dev/debt/libkernel.md
PR 9019 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 9097 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 9156 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9161 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 9162 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9199 docs/dev/debt/libkernel.md
PR 9242 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9293 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9297 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9302 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9326 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9383 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9537 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9557 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 9566 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 9684 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 9713 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 9843 docs/dev/debt/libkernel.md
PR 9938 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 9947 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 10016 core/libs/prx/libkernel_sys/Export.cpp
PR 10025 docs/dev/debt/libkernel.md
PR 10192 docs/dev/debt/libkernel.md
PR 10319 docs/dev/debt/libkernel.md
PR 10332 core/libs/prx/libkernel_sys/Export.cpp
PR 10335 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 10442 docs/dev/debt/libkernel.md
PR 10558 docs/dev/debt/libkernel.md
PR 10645 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 10657 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 10749 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 10806 core/libs/prx/libkernel/CMakeLists.txt
PR 11002 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 11031 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 11034 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 11212 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 11215 docs/dev/debt/libkernel.md
PR 11219 docs/dev/debt/libkernel.md
PR 11223 docs/dev/debt/libkernel.md
PR 11247 docs/dev/debt/libkernel.md
PR 11446 core/libs/prx/libkernel/CMakeLists.txt
PR 11624 docs/dev/debt/libkernel.md
PR 11625 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 11628 docs/dev/debt/libkernel.md
PR 11661 docs/dev/debt/libkernel.md
PR 11689 docs/dev/debt/libkernel.md
PR 11698 docs/dev/debt/libkernel.md
PR 11831 core/libs/prx/libkernel/CMakeLists.txt
PR 11891 core/libs/prx/libkernel/CMakeLists.txt
PR 11894 core/libs/prx/libkernel/CMakeLists.txt
PR 11896 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 11939 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 12104 docs/dev/debt/libkernel.md
PR 12130 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 12139 core/libs/prx/libkernel/CMakeLists.txt
PR 12149 core/libs/prx/libkernel/CMakeLists.txt
PR 12170 core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 12506 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 12544 core/libs/prx/libkernel/CMakeLists.txt
PR 12560 docs/dev/debt/libkernel.md
PR 12642 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 12682 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 12688 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 12700 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 12854 docs/dev/debt/libkernel.md
PR 12965 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 12970 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 13286 core/libs/prx/libkernel_sys/Export.cpp
PR 13336 docs/dev/debt/libkernel.md
PR 13504 docs/dev/debt/libkernel.md
PR 13506 docs/dev/debt/libkernel.md
PR 13560 docs/dev/debt/libkernel.md
PR 13582 docs/dev/debt/libkernel.md
PR 13587 docs/dev/debt/libkernel.md
PR 13695 docs/dev/debt/libkernel.md
PR 13950 docs/dev/debt/libkernel.md
PR 13953 docs/dev/debt/libkernel.md
PR 13964 docs/dev/debt/libkernel.md
PR 13995 docs/dev/debt/libkernel.md
PR 14039 docs/dev/debt/libkernel.md
PR 14043 docs/dev/debt/libkernel.md
PR 14085 docs/dev/debt/libkernel.md
PR 14101 core/libs/prx/libkernel_sys/Export.cpp
PR 14103 docs/dev/debt/libkernel.md
PR 14105 docs/dev/debt/libkernel.md
PR 14108 docs/dev/debt/libkernel.md
PR 14111 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 14128 docs/dev/debt/libkernel.md
PR 14183 docs/dev/debt/libkernel.md
PR 14190 docs/dev/debt/libkernel.md
PR 14206 docs/dev/debt/libkernel.md
PR 14212 docs/dev/debt/libkernel.md
PR 14216 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 14264 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 14272 core/libs/prx/libkernel/CMakeLists.txt
PR 14299 core/libs/prx/libkernel/CMakeLists.txt
PR 14310 docs/dev/debt/libkernel.md
PR 14320 docs/dev/debt/libkernel.md
PR 14324 docs/dev/debt/libkernel.md
PR 14325 docs/dev/debt/libkernel.md
PR 14417 docs/dev/debt/libkernel.md
PR 14493 docs/dev/debt/libkernel.md
PR 14497 docs/dev/debt/libkernel.md
PR 14548 core/libs/prx/libkernel_sys/Export.cpp
PR 14557 core/libs/prx/libkernel/CMakeLists.txt
PR 14566 core/libs/prx/libkernel/CMakeLists.txt
PR 14710 docs/dev/debt/libkernel.md
PR 14756 docs/dev/debt/libkernel.md
PR 14798 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 14832 docs/dev/debt/libkernel.md
PR 14841 core/libs/prx/libkernel/CMakeLists.txt
PR 14854 docs/dev/debt/libkernel.md
PR 14875 docs/dev/debt/libkernel.md
PR 14876 docs/dev/debt/libkernel.md
PR 14885 docs/dev/debt/libkernel.md
PR 14886 core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 14894 docs/dev/debt/libkernel.md
PR 14970 core/libs/prx/libkernel/CMakeLists.txt
PR 15000 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 15025 core/libs/prx/libkernel_sys/Export.cpp
PR 15030 docs/dev/debt/libkernel.md
PR 15035 docs/dev/debt/libkernel.md
PR 15037 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
docs/dev/debt/libkernel.md
PR 15040 docs/dev/debt/libkernel.md
PR 15041 docs/dev/debt/libkernel.md
PR 15046 core/libs/prx/libkernel/CMakeLists.txt
PR 15064 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 15095 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 15111 core/libs/prx/libkernel_sys/Export.Discovery.cpp

@wachi35676

Copy link
Copy Markdown
Contributor

Linux run, the platform the description doesn't list.

Head 02d83c7076 merged onto main a6dcea927 (clean). WSL2 Ubuntu 24.04, GCC 13.3.0, Release.

  • guest_sigqueue, guest_kill, guest_signals, guest_signal_list, guest_signal_sets: 5/5, 3 runs.
  • Negative control: with libkernel_sys/Export.cpp and Export.Discovery.cpp from main, guest_sigqueue aborts (sigqueue_nid_postfix not implemented).
  • check_conventions.py --base a6dcea927: passes.
  • The checks match FreeBSD 11.4 kern_sigqueue: (u_int)signum > _SIG_MAXSIG and pid <= 0 give EINVAL before pfind gives ESRCH, and signal 0 sends nothing.

sigqueue (TJG6tf+yJlY) is in the PS5 3.20 libkernel export list as well as libkernel_sys (libkernel.c L8893, libkernel_sys.c L9947). On Windows a libkernel import does not search libkernel_sys (core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp:175-177 adds libkernel only for libkernel_sys/libkernel_web imports). So a title that imports sigqueue from libkernel will not reach this implementation; #9379 moved swapcontext into libkernel for the same reason.

AI-assisted: yes (Claude Code); results above were run on this machine.

@xXPBSXx

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only guest_sigqueue_tests; ctest -N -R guest_sigqueue lists exactly one test.

PR head tested: 02d83c7076be46b4a6daea6d198e797619bfafb6.

Results (3 runs each):

  • PR head: guest_sigqueue passes 3/3.
  • Baseline: I kept the PR's test and replaced only these production files: core/libs/prx/libkernel_sys/Export.Discovery.cpp, core/libs/prx/libkernel_sys/Export.cpp with the version from the PR's merge base (cecb540a63), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.

GPU: the run output has no Selected GPU line; no GPU claim is made.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

@MarcZX10 MarcZX10 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested The new implementation is registered only in libkernel_sys, but sigqueue is exported by both libkernel_sys and libkernel in the PS5 3.20 export inventory (same NID, TJG6tf+yJlY). A title importing that NID from libkernel will therefore still hit the unimplemented path. The current Windows import fallback adds libkernel when resolving imports from libkernel_sys or libkernel_web; it does not add libkernel_sys when resolving imports from libkernel. The current tree likewise has no sigqueue implementation/export in core/libs/prx/libkernel. Please cover the libkernel export too, with a test that imports through each module, or provide repository-specific evidence that the libkernel export is not required and adjust the stated scope accordingly. The independent PS5 export-inventory references are in the Linux test report comment above; the relevant fallback is core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp. ## Base and overlap coordination

I withdraw the queue-based intake hold. It is fine to keep submitting PRs; maintainers will handle them in due course.

The PR is also substantially behind current main (the checked base is d6732b51a64f4322799af89b876b224d3aed6efc; this head is 588 commits behind and 1 ahead). Please rebase/update and rerun checks before requesting another review. The overlap report also flags the shared libkernel_sys debt entry with #9195 and cannot compare multiple shared CMake/Export.cpp files due to base conflicts; manually coordinate those changes after updating. ## Checks observed - python3 tools/check_conventions.py --base upstream/main: passed. - git diff --check upstream/main...refs/review/9389: passed. - Local Linux guest_sigqueue_tests target: built successfully. - Local guest_sigqueue runtime: could not execute; the host CPU lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, and FMA, which the project requires. - Existing hosted eligibility, conventions, intake, labels, and report checks passed on this PR head. Product build jobs were skipped. - The PR and independent Windows/WSL2 reports provide additional platform runs; I did not reproduce those locally.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

sigqueue follows FreeBSD 11 sys_sigqueue: EINVAL for a signal above 128
or a pid of 0 or below, ESRCH for another process, signal 0 only checks,
and the guest's own pid gets the signal through libkernel's raise. The
value is dropped, as libkernel delivers signals without siginfo.
…_sys to it

The PS5 3.20 libkernel exports sigqueue under the same NID as libkernel_sys
(TJG6tf+yJlY), and the Windows import fallback only looks in libkernel for
libkernel_sys imports, not the other way. The implementation moves next to
kill in libkernel as sigqueue_nid_disambig1, as fstat and pwrite are there,
libkernel_sys's export forwards to it, the test runs every check through
both exports and the debt entry moves to libkernel.
@GitamarT045T3R
GitamarT045T3R force-pushed the feat/libkernel_sys-sigqueue branch from 02d83c7 to bddbe58 Compare October 22, 2026 08:15
@GitamarT045T3R

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks for catching the libkernel export. Rebased onto main d6eafa54d, plus bddbe58:

  • libkernel: sigqueue is now implemented in libkernel, next to kill in Signals.cpp, as sigqueue_nid_disambig1, so it exports the same NID TJG6tf+yJlY. That is how fstat and pwrite are shared between the two modules.
  • libkernel_sys: its sigqueue forwards to libkernel's, so both imports reach one implementation.
  • Test: guest_sigqueue now runs every check through both exports.
  • Debt entry: moved to libkernel.md, so this no longer shares the libkernel_sys debt hunk with feat(libkernel_sys): implement uuidgen #9195.

Tested:

  • On Windows, guest_sigqueue, guest_kill, guest_signals and guest_kernel_sys pass, and check_conventions passes.
  • The NID-patched libkernel.prx exports TJG6tf+yJlY. libkernel_sys.prx exports it and imports it from libkernel.prx.
  • git merge-tree against the open PRs that touch these files finds no new conflicts.

On intake: no title is known to need sigqueue yet, so I leave it to the maintainers whether this waits under the #5239 guidance.

@Gruzzberry Gruzzberry mentioned this pull request Oct 22, 2026
12 tasks done

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran bddbe58 on native Linux (Ubuntu 26.04, glibc 2.43, x86_64 i7-8700, GCC 15.2.0, Release, merged --no-commit onto origin/main 7e2ba73). guest_sigqueue, guest_kill, guest_signals, guest_kernel_sys and patched_libraries pass.

One problem with the new forwarder on the NID-patched libraries. After patching, libkernel_sys.prx both exports TJG6tf+yJlY and imports it (its sigqueue_nid_postfix is jmp TJG6tf+yJlY@plt):

$ readelf -W --dyn-syms build/core/libs/libs/libkernel_sys.prx | grep TJG6tf+yJlY
    76: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND TJG6tf+yJlY
   357: 000000000000df30     9 FUNC    GLOBAL DEFAULT   13 TJG6tf+yJlY

There's no symbol versioning, so that import binds to the first TJG6tf+yJlY in the lookup scope. If libkernel_sys.prx comes before libkernel.prx, it binds to itself and sigqueue never returns. The relinker keeps the title's DT_NEEDED order, so a title that lists libkernel_sys first hits this. A minimal executable linked against the patched .prx files, which looks up TJG6tf+yJlY and calls it with (-1, 1, nullptr):

  • DT_NEEDED libkernel_sys.prx, libkernel.prx: resolves to libkernel_sys.prx, spins until timeout 15 kills it.
  • DT_NEEDED libkernel.prx, libkernel_sys.prx: resolves to libkernel.prx, returns -1.

guest_sigqueue can't see this because it links the unpatched libraries, where the two names are still different. Calling a helper that patching leaves alone would avoid it, for example Sigqueue_nid_no_patch in libkernel's Signals.cpp called by both exports, the way #9693 uses SetLogin_nid_no_patch across the same two modules.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

After NID patching libkernel_sys's sigqueue forwarder imported the NID it
exports itself, so on ELF hosts it could bind to itself when libkernel_sys
comes before libkernel in the lookup order. Both exports now call
GuestSigqueue_nid_no_patch in libkernel, which patching does not rename,
as GuestAlarm_nid_no_patch is shared with libSceLibcInternal.
@GitamarT045T3R

Copy link
Copy Markdown
Contributor Author

@jotitadev thank you, that self-binding is real: after patching, the forwarder's import and the export are both TJG6tf+yJlY. Fixed in 3a75bf4. Both exports now call GuestSigqueue_nid_no_patch in libkernel's Signals.cpp, which patching leaves alone, as GuestAlarm_nid_no_patch is shared with libSceLibcInternal.

On the NID-patched libraries (Windows build), libkernel_sys.prx still exports TJG6tf+yJlY and no longer imports it. It imports GuestSigqueue_nid_no_patch from libkernel.prx, and libkernel.prx exports both. guest_sigqueue, guest_kill, guest_signals and guest_kernel_sys pass, and check_conventions passes.

@Gruzzberry

Copy link
Copy Markdown
Contributor

For the record: #9682 (settimeofday) removes the stub next to sigqueue in Export.Discovery.cpp. #9682 will go after this PR and rebase; nothing is needed here. Its checklist now says so.

@MarcZX10

Copy link
Copy Markdown
Contributor

I’ve noticed that my earlier request to hold this PR based on #5239 was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. Please disregard that request.

danielradosa added a commit to danielradosa/AnyPS5 that referenced this pull request Oct 24, 2026
Took the PR's structure (libkernel helper GuestSigqueue_nid_no_patch, libkernel's sigqueue_nid_disambig1 export, libkernel_sys's sigqueue calling the helper) but with our implementation, which queues the value with SI_QUEUE through GuestSignalQueue where the PR raises without it; moved our debt line to libkernel.md in place of the PR's; the PR's test now runs only the libkernel export (guest_kernel_sys_ipc covers the libkernel_sys one).
@adriadam10 adriadam10 self-assigned this Oct 25, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 12:31

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@Gruzzberry

Copy link
Copy Markdown
Contributor

Hi @GitamarT045T3R, the overlap check shows my open PR next to this one:

The changes are separate. Only the neighbouring lines overlap. Proposed merge order: this PR first, then #11026, which I'll rebase onto it after it merges. I've recorded that under Depends on in #11026. If you'd prefer to go second, say so and I'll switch it.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@wachi35676

Copy link
Copy Markdown
Contributor

Re-checked head 3a75bf4610 against main 2b5225605, on Windows 11 with WinLibs GCC 15.2.0 and WSL Ubuntu 24.04 with GCC 13.3, both Release.

It needs two changes to build on current main:

  1. libkernel_sys/Export.Discovery.cpp conflicts with feat(libkernel_sys): implement settimeofday #9682, which removed the settimeofday stub next to sigqueue. Dropping both stubs resolves it.
  2. Then Export.cpp:338 fails with conflicting declaration of C function 'int sigqueue_nid_postfix(int, int, void*)'. refactor(libs): add full export headers for libs #10706 (f38d29fd0) added core/libs/prx/libkernel_sys/include/Api.hpp, whose line 537 declares the stub as int APS5_VABI sigqueue_nid_postfix(void);. Changing that line to int APS5_VABI sigqueue_nid_postfix(int pid, int signal, void* value); fixes it, as feat(libkernel_sys): implement settimeofday #9682 did for settimeofday.

With those two changes, guest_sigqueue, guest_kill, guest_signals, guest_signal_list, guest_signal_sets, guest_kernel_sys and patched_libraries pass 7/7 on Windows and Linux, 3 runs. guest_sigqueue covers both exports through the shared GuestSigqueue_nid_no_patch. With its EINVAL check removed, guest_sigqueue fails.

AI-assisted: yes (Claude Code); results above were run on this machine.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-ran the self-binding case from my earlier review on 3a75bf461: it is fixed.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, glibc 2.43, GCC 15.2, Release, BUILD_TESTING=ON, full build. Head 3a75bf461 merged --no-commit onto main abed03546, with the two changes @wachi35676 described to make it build (drop the sigqueue and settimeofday stubs in Export.Discovery.cpp, and the three-argument sigqueue_nid_postfix declaration in libkernel_sys/include/Api.hpp).

  • NID-patched libraries: libkernel_sys.prx exports TJG6tf+yJlY and no longer imports it. Its only related import is GuestSigqueue_nid_no_patch, which libkernel.prx exports next to its own TJG6tf+yJlY.
  • Same minimal executable as before, dlsym(RTLD_DEFAULT, "TJG6tf+yJlY") called with (-1, 1, nullptr):
    • DT_NEEDED libkernel_sys.prx, libkernel.prx: resolves to libkernel_sys.prx, returns -1.
    • DT_NEEDED libkernel.prx, libkernel_sys.prx: resolves to libkernel.prx, returns -1.
  • Control, with Signals.cpp and libkernel_sys/Export.cpp as in bddbe58a2 (the forwarder): libkernel_sys.prx imports TJG6tf+yJlY again, and the libkernel_sys-first executable spins until timeout 15 kills it. guest_sigqueue still passes on that control, since it links the unpatched libraries.
  • guest_sigqueue 3/3. guest_sigqueue, guest_kill, guest_signals, guest_signal_list, guest_signal_sets, guest_kernel_sys, patched_libraries and conventions_unknown_nids pass, 8/8.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@GitamarT045T3R Thanks. This no longer merges with main: main has since implemented sigreturn and profil next to the lines this edits, in libkernel_sys/Export.Discovery.cpp and Export.cpp, and the docs/dev/debt/libkernel.md list moved. Could you merge main? Keep its sigreturn and profil, delete its sigqueue stub, and keep both sets of debt entries.

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

build docs libkernel needs rebase Conflicts with main, rebase needed prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants