Skip to content

test(relinker): cover host libc collisions in guest imports - #15585

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
HenriksApsitis:test/linux-guest-host-libc-collision
Nov 7, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
HenriksApsitis:test/linux-guest-host-libc-collision

Conversation

@HenriksApsitis

Copy link
Copy Markdown
Contributor

What

Extend linux_guest_named_imports with a symbol that the host C library actually exports: getpid. Existing shared cases cannot catch a guest import being silently satisfied by host libc.

  • A synthetic NID provider returns zero, while native getpid must return a positive PID. The module initializer checks the NID-provider result before the executable can exit with its success marker.
  • A second provider omits the NID but still links host libc. Conversion must retain the undefined NID, and native execution must fail rather than fall back to libc's literal getpid.
  • Each provider is checked for a dynamic dependency and loaded in a separate native Python process to verify both its explicit host-PID control and libc's getpid remain available.

This covers the host-libc binding mechanism reported in #9261, following #9180/#9234. No production behavior changes, new dependencies, console-behavior claims, or new title-unblocking claim.

Tested

Linux x86-64 VM, Debian 13, GCC 14.2.0, Release relinker-only build, CTest Python 3.11.15. No GPU or proprietary inputs.

  • Base 086c0686c8adff3ee648fdbe34e0b0b647e1d511: full build succeeded; 678/680 CTests passed. masked_store_lowering and amd64_only_converter terminate with illegal instructions on this VM.
  • Candidate: 678/680 CTests passed, with exactly the same two failures; the extended linux_guest_named_imports test passes (focused run 0.26 s).
  • Built actual historical main 1bf232a64bff04497e272abe2a6a4c90ad061a4c, immediately before the fix(relinker): bind SDK guest module imports on Linux #9261 merge. An independent synthetic runtime probe reproduces the wrong binding with the NID present and absent: LD_DEBUG=bindings identifies the module's getpid provider as /lib/x86_64-linux-gnu/libc.so.6; the fixture's deliberate wrong-result UD2 guard fires in both cases.
  • Historical-probe controls: ordinary zero ELF-ident padding avoids a separate old padding defect. A .sprx symlink to the exact same .prx provider bypasses the old dependency-suffix failure, as described in fix(relinker): bind SDK guest module imports on Linux #9261, without changing symbol binding. The probe uses the same synthetic module call, providers and current host fixture across both relinkers.
  • With the current relinker the same probe binds HoLVWNanBBc to available.prx and exits 42; without that NID it reports undefined symbol: HoLVWNanBBc and exits 127, despite host getpid being available.
  • Repeated linux_named_imports and linux_guest_named_imports ten times each with CTest --repeat until-fail:10: all 20 executions passed (about 4 s total).
  • Independent code review of the exact committed patch: passed, no security or logic findings. The provider-dependency assertion is intentionally SONAME-independent; the native controls also verify host getpid resolution.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • git diff --check: passed.
  • python3 tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch test/linux-guest-host-libc-collision --jobs 4: completed against 1,762 open PRs; no shared files/exports and no overlap found.

Native Windows/macOS execution and full system-library builds were not performed; this test's runtime cases are gated to Linux x86-64. The full local suite is not claimed green.

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

@adriadam10 adriadam10 self-assigned this Nov 7, 2026
@adriadam10
adriadam10 merged commit cbe1ca8 into boykopovar:main Nov 7, 2026
14 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the new getpid cases (NID present: native must return the provider's 0 and exit 42; NID absent: the undefined NID must stay and exit 127), the control that each provider depends on host libc, and that the PR's relinker CI jobs are green; merged.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants