Skip to content

test(relinker): guard against duplicate module preinit startup - #15255

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
HenriksApsitis:test/reported-relinker-regression
Nov 3, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
HenriksApsitis:test/reported-relinker-regression

Conversation

@HenriksApsitis

@HenriksApsitis HenriksApsitis commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Extend guest_zero_initializer with a module whose DT_INIT dispatches its own DT_PREINIT_ARRAY entry. Record a distinct callback marker and require the exact sequence: one callback, the original initializer arguments, then its return value. Retain the zero-address and no-preinit controls, add a nonzero initializer, and check exact events for deferred Linux initialization.

This guards against #7636, the title-startup regression introduced by #6112 and reverted by #7646. The previous preinit fixture callback merely returned 42, so it did not make its invocation count observable. No production code changes and no newly unblocked title are claimed.

Tested

Debian GNU/Linux 13 x86-64, GCC 14.2.0, Python 3.11.15, relinker-only Release configuration (ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON), synthetic fixtures only.

  • Fresh configure and build of this PR's exact head 3577e0368a4b4bb3f6c08dd6dd906de867966055: pass.
  • Full ctest --test-dir build-relinker --output-on-failure --parallel 2: 588/590 pass. masked_store_lowering and amd64_only_converter terminate with SIGILL; both fail identically on unchanged main on this restricted virtual CPU. No new failures.
  • Seven focused module-lifecycle scripts pass, including guest_zero_initializer, guest_module_args, deferred dependencies, unused import dependencies, module directory handling, zero finalizers and module finalization.
  • Built actual historical bad commit 376c040294370ce7de355485947d5d00a9417e29. This test fails on its first native event assertion because the callback marker is emitted twice:
args=0000000000001357 argp=0000000000002468
args=0000000000001357 argp=0000000000002468
args=1122334455667788 argp=99aabbccddeeff00
result=23063

On current main and this head, the first marker appears once, followed by the unchanged initializer arguments and return value. This is the reported double-startup mechanism, not a mocked filesystem failure or an unrelated conversion rejection.

Linux native loading executed. Windows PE and macOS Mach-O conversion/structural checks executed; native Windows/macOS loading, full guest libraries, GPU tests and real titles were not run. No performance claim.

python3 tools/check_conventions.py --base origin/main and git diff --check pass. python3 tools/pr_overlap.py --branch test/reported-relinker-regression --repo boykopovar/AnyPS5 --base main --jobs 4 completed against 1,730 open PRs with no overlap.

Independent read-only review of this exact head checked the x86-64 encodings/RIP-relative targets with objdump, SysV stack alignment, register/argument preservation and exact event assertions. It reran current and historical binaries and found no blocking logic issues. Native Windows/macOS execution remains unverified.

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

Model a module whose initializer dispatches its own preinit callback and assert the exact once-only callback, preserved arguments and return value. Retain zero-address and no-preinit controls and cover deferred Linux initialization.

Regression coverage for boykopovar#7636, introduced by boykopovar#6112 and reverted by boykopovar#7646. The new test fails with the actual historical bad relinker at 376c040 and passes on main 9090972.

AI-assisted: yes. Independently reviewed staged patch 6e437226c361065dad96478101fc899f65cde86caf51a39415369c01c1725168.
@oneandonlydean oneandonlydean self-assigned this Nov 3, 2026
@oneandonlydean
oneandonlydean merged commit e231f17 into boykopovar:main Nov 3, 2026
4 of 5 checks passed
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