fix(prx): keep forwarding exports from binding to themselves on Linux #13730
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13730"
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 GiannisG1 on 2026-10-31T02:59:09Z.
What
Six libraries forward an export to another library's function of the same NID:
opendir,closedir,readdir,readdir_r(#12386,*_nid_disambig1_nid_postfix)opendir_nid_postfix…sceAmprWcstombsS(sZLrjx-yEx4)wcstombs_s_nid_postfix(sZLrjx-yEx4)Aio.cpp(and its own unimplementedpwrite_nid_postfix,C2kJ-byS5rM)pwrite_nid_disambig1_nid_postfix(C2kJ-byS5rM)_dup2(W8f1adVl+48),_execve(ScfDTOqLOMw),_execvpe(-3nj+K1elI0),*_nid_disambig1_nid_postfix(418e5c817b, 2026-11-07)_dup2_nid_postfix,_execve_nid_postfix,_execvpe_nid_postfix(same NIDs)FT_Stroker_Export(2rcvKZfm5rI,4a71da0821, onmainsince 2026-11-12)FT_Stroker_Export_nid_postfix(same NID)new[]nothrow (s2eGsgUF9vk) and aligneddelete[](v09ZcAhZzSc) inAlignedNew.cpp(#14240); the tenstd::numpunct<char>members inNumpunct.cpp(#14373):decimal_point,thousands_sep,grouping,truename,falsenameand theirdo_versions;time_put<wchar_t>::_Getcat(bF2uVCqVhBY) inFacetPut.cpp(8cde12b69e, onmainsince 2026-11-15)_ZnamSt11align_val_tRKSt9nothrow_t_nid_postfixand_ZdaPvSt11align_val_t_nid_postfix; libc's_ZNKSt8numpunctIcE…_nid_postfix; libc's_ZNSt8time_putIw…7_Getcat…_nid_postfix(same NIDs)After NID patching the import and the library's own export have the same name, for example
ay3uROQAc5Ain libScePosixForWebKit (nm -D:U ay3uROQAc5AandT ay3uROQAc5A). On Linux the import binds to the first definition in the lookup scope, and when the library comes before the provider it binds to its own export. libScePosixForWebKit'sopendirisjmp ay3uROQAc5A@plt, so it jumps to itself forever: Apotris (PPSA98513), FFTARecomp (PPSA98512) and DevilutionX (PPSA98514) hang at start at about 95% of one core with no system calls, and gdb samples are always inopendir_nid_disambig1_nid_postfixor that PLT entry. WithLD_PRELOADof the patchedlibc.prx, which puts libc first in the scope, Apotris starts.sceAmprWcstombsS, libSceLibcInternal's two aligned forwarders, libkernel_web's three and libSceFreeTypeOt's one can loop the same way, and an AIO write can reach libkernel_sys'sNotImplementedpwrite. PE and Mach-O imports name their library, so Windows and macOS don't have this.Each provider now keeps the body in a
_nid_no_patchfunction (OpenDirectory,ReadDirectory,ReadDirectoryEntry,CloseDirectory,WideToMultibyteChecked,AlignedArrayNewNothrow,AlignedArrayDelete, the tenNumpunct…functions such asNumpunctDecimalPointandNumpunctDoDecimalPoint, libkernel_sys'sGuestDup2,GuestExecveandGuestExecvpe, libSceFreeType'sStrokerExport, libc'sLibcWideTimePutGetcat, and #9019'sPosixPwrite), its export calls that function, and the forwarders call it too. The body has to move, because a_nid_no_patchwrapper that called the exported name could itself be interposed. Nothing changes in what the functions do.patched_self_imports(Linux, depends onlibs, likewindows_import_identity) reads the dynamic symbols of every.prxincore/libs/libsand fails for an import whose name the same library exports. Without the fixes it reports the eight names of the first four rows, since #14373 the tennumpunct<char>members, since418e5c817blibkernel_web's three, since4a71da0821libSceFreeTypeOt's one, and since8cde12b69elibSceLibcInternal'stime_put<wchar_t>::_Getcat(the first 21 are the namesnm -Dshowed both imported and exported in the patched libraries ofmain3a0a54bbd8; the last two are what the test printed onmain4a590b5085andb7aeb6f406with the other fixes in):With this PR:
No patched library imports a name it exports (413 libraries).Landing order (CONTRIBUTING: overlapping PRs agree an order): #9019 is merged (
0db469c769), and this PR's head merges cleanly with currentmain.pwritethePosixPwrite_nid_no_patchhelper. Since the rebase ontod63781e9cethis PR no longer carries that hunk; it only calls the helper from libkernel_sys's AIO write.LocaleSupport.cpp(both blocks kept; whichever merges second rebases, and I'll do it for this one); #18190 and #18112 are stacked on this PR's commit and rebase after it; #16823 and #17865 add code next to libSceFreeTypeOt'sFT_Stroker_Exportforwarder (adjacent lines, not the same function); #20047 restores libSceFreeTypeOt'sFT_Outline_Get_Bitmapforward (#19411, reverted by #19762 because it imported its own NID4RRjK-Wd1lU) with the same convention as here, and merges cleanly with it. #17300 renames libSceLibcInternal's inventory placeholders, among them thetime_put<wchar_t>::_GetcatNID thatmainhas implemented since8cde12b69e(it conflicts withmainthere, not with a line of this PR). #18659 (_wait4) was merged first on 2026-11-12, and this head is rebased over it; #18122 was re-scoped the same day and no longer forwards anything.pwrite's body for cancellation, which meets #9019's lines inmain, not a line of this PR's own.Tested
Linux Mint 22.3, kernel 7.0.0-38, GCC 13.3.0, Release,
BUILD_TESTING=ON, head6c5bee0282onmainb7aeb6f406. The titles ran on earlier heads, before the rebases that added the alignednew/delete, thenumpunct<char>, the libkernel_web, the libSceFreeTypeOt and thetime_putforwarders: the first headfe58f461d6, which differs only in the name of the pwrite helper and where the test is registered, ande9e816f6c7for I Wanna Be The Guy.Catalog titles, converted with
--to-intel, 60 s each under Xvfb on an NVIDIA GTX 1050 Ti (580.178.04):mainopendiropendir(gdb)e9e816f6c7)On this head: rebased onto
b7aeb6f406,patched_self_importsfailed with thebF2uVCqVhBYline before thetime_putfix and passes with it (413 libraries);guest_localeandguest_libc_internal_facet_putpass. All tests once and every GPU test on each of the three devices, under Xvfb, against a--fullrun ofmain3a0a54bbd8: NVIDIA GTX 1050 Ti 5621 run, 0 failed; Intel HD Graphics 630 (Mesa 25.2.8) 1822 run, 9 failed; llvmpipe 1822 run, 11 failed. Run alone three times each, five of those pass 3/3 (agc_driver_frame_replay_rewind_copy,agc_driver_runtime_buffer_spans_x{2,3,4}_spans,guest_kernel_sys_paths_readlinkat_limits). The other 15 fail 3/3 alone, and fail the same way 3/3 on unmodifiedmainb7aeb6f406built on the same machine: on both devicesagc_draw_input_mirrorsandagc_draw_input_reuse; on the HD Graphics 630agc_driver_gcn_display_presentand…_present_trigger(no DRI3 under Xvfb),agc_driver_image_sample_lod_clampand the threeagc_driver_native_color_{readback,snapshot,snapshot_refusals}; on llvmpipeagc_driver_coherent_atomic_loads_enabled(timeout),agc_driver_global_atomic_csub,agc_driver_host_write_shadowed_unit,agc_driver_stencil_copy_drawandagc_driver_scattered_runs("allocation failure closed the backing descriptor" on both; on this head one earlier set of three ended in an exception instead).guest_icu_recovered_signatures_testsdoes not link onb7aeb6f406itself (fixed onmainby #20844).The tests nearest to the changed code (
patched_self_imports, the directory, multibyte, POSIX-for-WebKit, AIO, Ampr, alignednew/delete,numpunct, locale, FreeType andguest_kernel_web_forwards) are in that run and pass (the suite runs a test on one device when the--fullrun showed it does not depend on the GPU;patched_self_importsran on all three).check_skips.pynames no unexpected skip on any device.check_conventions.py,check_test_registration.py,check_main_sync.py,check_compile.pyandgit diff --checkare clean;pr_overlap.py --branchlists only the PRs in the landing-order paragraph.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T03:29:19Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The fix is supported by the reported Linux testing, but overlapping open changes need an agreed landing order and two title-unblock entries lack their required discussion references.
What I ran
Reviewed head
fe58f461d6a5e7685333adab1ad6c347b914933bagainst PR basee2df06e661f94d6e63b8f6622c8c58507b0245c1. The live merge preview ontomain6475267b456de6a0a23b230aa751f0b917d12688was clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build locally or run CTest.Results
mainat6475267b456de6a0a23b230aa751f0b917d12688.passed_with_warnings; thesceAmprWcstombsSalias warning concerns its explicit NID, while this PR changes only its call body.conventionseligibilityintakelabelslibrary-portabilityreportlinuxmacos-latest, clang++windowsjobUnedited output excerpts
check_conventions.py:The test-quality helper output for the new C++ test:
Relevant overlap-scan rows (the scan used current
main6475267b456de6a0a23b230aa751f0b917d12688):Manual patch inspection found #7645 changes a different CMake hunk, so it is not a substantive overlap here. The scanner could not compare several branches that conflict with the base; this PR's own description also identifies #12700 and #12965 as touching the positioned-write change.
Latest relevant
gh pr checksoutput:Negative control
Findings
Blocking
CONTRIBUTING.mdrequires authors of overlapping PRs to agree on landing order and record it withDepends on. The live overlap scan found open #9019 changing thepwriteprovider path and #12868 changing the AIO call. This PR's description also names #12700 and #12965 as touching the positioned-write code. The checklist currently saysDepends on: none, and no coordination is recorded. Please agree on the landing order with the affected authors and update the checklist accordingly.Unblocksline listsPPSA98514andPPSA20040without their Game bring-up discussion references. Add the applicable discussion IDs or remove entries that are not tracked there.Non-blocking
The description reports substantial Linux and title testing but does not state the exact PR head SHA those results exercised. Please add the full tested head SHA so the evidence can be matched to this revision.
Sources
mainmainNot verified
No local compilation, CTest, title launch, console behavior, or negative-control mutation was run. The Linux-specific test is not covered by the hosted Linux job because that job was skipped; macOS and full Windows jobs were pending. The exact PR head used for the author's reported tests is unspecified. The overlap scan could not compare some branches that conflict with the PR base, so they still need manual review before concluding no additional overlap exists.
To get this to a good state
Please coordinate and record the overlap order, complete the missing Game bring-up references, and add the exact tested head SHA. I will rerun the relevant checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T21:54:13Z.
Review: APPROVED
Reviewed — approved
Moving the eight self-forwarded bodies into
_nid_no_patchhelpers removes every self-import from the patched libraries on Linux. The newpatched_self_importstest passes on the merged tree, and withmain's production files it fails and lists exactly those eight names.What I ran
Head
905617771ee037b6855f27750d9d8480a4e851a4, merged with--no-ffintomain9090972b7e91fd266819cbd77a8b058e177b5682(merged treea200042f4212607ed244e8a51a9c4b5ca8ee051e). Debian 13 VM, 32 vCPU Xeon Gold 6136, GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON, lavapipe (Mesa 26.1.6).Results
git diff --checkcheck_conventions.pylibs(script)main. The unexpectedguest_net_ctlskip also happens onmain.patched_self_importsat 0.99 spatched_self_importson the merged treeNo patched library imports a name it exports (405 libraries)git status --porcelainis emptyNegative control output
Negative control
I restored all 11 non-test files the PR changes from
main. The test registration incore/libs/CMakeLists.txtandPatchedSelfImports.cppstayed as merged. After rebuildinglibs,patched_self_importsfailed and reported the same eight self-imports the description lists. These include the two libSceLibcInternal ones that B-Howell found in their comment. I then restored the merged files and rebuilt, and the test passed again (405 libraries). The worktree matched the merged tree at the end.Findings
Blocking
None.
Non-blocking
Depends online doesn't match the author's comment. In the 2026-10-31 reply to MarcZX10, the author wroteDepends on: #9019, #12868, and said this PR would rebase onto #12868'sAio.cppstructure once that PR lands. The current checklist names only #9019. The new call atcore/libs/prx/libkernel_sys/Aio.cpp:98is the line #12868 restructures, according to MarcZX10's review. Either restore #12868 on the line or say on the PR that the order with #12868 no longer matters. This keeps the landing-order record CONTRIBUTING asks for consistent.WideToMultibyteChecked_nid_no_patch(core/libs/prx/libc/src/Multibyte.cpp:372),AlignedArrayNewNothrow_nid_no_patchandAlignedArrayDelete_nid_no_patch(core/libs/prx/libc/src/StdioExtras.cpp:171,:191) andPosixPwrite_nid_no_patch(core/libs/prx/libkernel/File/src/Stdio.cpp:1117) have noAPS5_VABI. The directory helpers do have it. All callers are host code, and each declaration matches its definition, so this is correct. It is only noted as an inconsistency between the helpers.Not verified
fe58f461d6.git merge-tree. That needs the other PR's head, and the sandbox has no network.Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T23:30:23Z.
Review: COMMENTED
Read
dee26988a2againstmain.Still needed: current
mainstill has all eight forwarders (libScePosixForWebKitExport.cpp:281-294,sceAmprWcstombsS, libSceLibcInternalAlignedNew.cpp:9-17, libkernel_sysAio.cpp:104). Each body moves unchanged into a_nid_no_patchfunction that NID patching leaves alone, and both the export and the forwarder call it, so no import shares a name with its own library's export and behaviour doesn't change on any OS. Every new helper is declaredextern "C"in a header the defining file includes (Multibyte.cppnow includesGeneral.hppfor that). No finding in the code.The
windowscheck is red because it was cancelled at the 45-minute limit while still compiling, so this head has no Windows result; it needs a re-run.The new test has never run in CI.
patched_self_importsis registered only on Linux and the hostedlinuxjob is skipped on pull requests. The branch is about 4,200 commits behindmain, and #14240 already added two self-forwarders after an earlier push, so a rebase and a run ofpatched_self_importson the result would catch any that landed since.Not run here; this is from reading the code.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T11:35:27Z.
Review: COMMENTED
Windows check of head
0da91e53be, merged ontomain105c9e4d91(clean merge). ThewindowsCI job hasn't finished on this head, so this fills that gap.Setup: Windows 11, WinLibs GCC 15.2 (
x86_64-ucrt-posix-seh), Release, full build withBUILD_TESTING=ON.numpunct<char>bodies inLocaleSupport.cppandNumpunct.cppand the new declarations inGuestLocale.hpp.opendir2,fdopendir, POSIX-for-WebKit, AIO, Ampr,wcsrtombs, alignednew/delete, new-handler,nid_patcher_symbol_versions,guest_libc_internal_numpunctand locale tests.patched_self_importsis registered only on Linux, so it didn't run here.I ran no negative control: a Windows import is bound to the DLL it names, so the self-binding this fixes can't happen on PE. What this shows is that moving the bodies into
_nid_no_patchfunctions changes nothing on Windows.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T01:58:46Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The updated head records the title references, but its checklist still does not record an author-agreed order for several open overlapping PRs, as
CONTRIBUTING.mdrequires.What I ran
Reviewed head
a94a4be4aad794d770e388715b10787a333574c5against currentmain077a573cd1dab3d2fa2dbe6e508fa46118bce4cc. The merge preview is clean (tree2fb47210038543b906143cb071091ba7a6e2e5f1). Environment: Linux x86-64, Python 3.11.2, GCC 12.2.0.I read the full 17-file diff and the current overlap/checklist discussion. The precheck pinned the same head and base before and after the run.
Results
patched_self_importsCTest registration.libsbuild was made here.Precheck table, commands and captured output
The precheck's exact table:
git diff --checkon the pinned base and head.Captured command output:
The CI snapshot from
gh pr checksshowedwindows pendingandlinux skipping; the relinker, register-context, edge-watch, write-watch, conventions, eligibility, report, and library-portability jobs shown in that output passed.Negative control
The PR description reports a pass on the PR and a failure on an older
mainsnapshot; I did not independently reproduce that control on this head and current base.Findings
Blocking
The
Depends on: noneline is not sufficient for the four still-open overlaps listed in the PR description. Current heads still overlap this change: #18135 atLocaleSupport.cpp, #18659 at_execvpeinAdditionalExports.cpp, #18190 at theAio.cppwrite call, and #18122 at the forwarded libc exports. The #18190 author explicitly says the same AIO line is changed and that #13730 would be rebased if #18190 lands first; that is not an agreed landing order.CONTRIBUTING.mdrequires agreement with the affected authors and recording the order inDepends on.Please agree with each affected author which PR lands first, then record the resulting dependency on this checklist. If an overlap no longer applies, update the overlap list with the current evidence.
Non-blocking
The earlier missing
Unblocksreferences are now present for PPSA98513 and PPSA98512. The clean current-base merge preview means the branch does not need a rebase merely for being behindmain.Sources
077a573c_execvpechangesNot verified
patched_self_imports; Linux CI is skipped, so it supplies no result for that test.To get this to a good state
Record the agreed order and
Depends online for the remaining live overlaps. I will rerun the same precheck and re-review the new head after that update; the hosted Windows check also needs to finish before approval can be considered.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T19:46:27Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
378d91827e8fbe79b2560cd4703762d54a953d9e, basemain. No merge preview.files.jsonunderreviewed; none were excluded. Full text was not read for any file.Results
patched_self_importsFindings
Blocking
None.
Non-blocking
None found in the code read.
Sources
core/libs/prx/libkernel_sys/Aio.cpp:115now callsPosixPwrite_nid_no_patch. libkernel'spwrite_nid_disambig1_nid_postfixcalls the same helper:github.com/boykopovar/AnyPS5@378d91827e/core/libs/prx/libkernel/File/src/Stdio.cpp (L1286-L1287)Not verified
GuestDup2_nid_no_patch,GuestExecve_nid_no_patch,GuestExecvpe_nid_no_patch,StrokerExport_nid_no_patchand the libc helpers (NumpunctDo…_nid_no_patch,AlignedArrayNewNothrow_nid_no_patch,OpenDirectory_nid_no_patchand others) are called from other libraries withoutAPS5_EXPORT. Whether they are dynamic symbols depends on the build's symbol visibility, which I did not check.fe58f461d6,e9e816f6c7,4a590b5085), not378d91827e8f.patched_self_imports.To get this to a good state
Nothing is required.
Optional: name the head that the test table was run on. It lists three earlier heads, so the table does not show a run on this head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T20:02:39Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and targeted test support the stated fix, while execution checks were not run during this review.
What I ran
No commands or tests were run. I reviewed head
6c5bee0282cee61ea578b2e75f93caefac0337b1from the prepared diff and the repository reader; the author-reported checks in the PR description were not run by me.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build, tests, or runtime behavior were independently verified. The PR description reports those results, but they are author-supplied. No files were excluded from review according to the prepared manifest.
To get this to a good state
Nothing is required.