test(relinker): verify entry-stub bounds before allocation #7704
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7704"
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 rajvveer on 2026-10-19T01:49:55Z.
What
The runtime boundary test in #6204 passes with and without its allocation guard. The separate CMake test searches for literal source strings, so it cannot establish that the guard runs before
resize.Depends on #6204 (included). The first commit,
26375a30ef, is @vrebel11's production guard rebased ontomain, with authorship preserved. My contribution is the second commit,36eeec6bb5: test coverage and registration only. This remains a draft for coordinating the follow-up while #6204 is open; the test commit can also be cherry-picked into #6204.operator newrecords the largest allocation, followingUseRewriteAllocation.cpp. With 4096 bytes left belowINT32_MAX, the builder must reject the 64 KiB startup buffer before allocating it.INT32_MAX. UseWindowsImportBuilderfor the imports instead of a second list of function names.windows_entry_stub_boundson every host, with a 20-second timeout. RemoveWindowsEntryStubEndpointGuard.cmakeand its registration; fix the trailing newline and spacing.This addresses the review on #6204. It does not establish a fix for the intermittent GCC crash in #5927.
Tested
Windows x64, WinLibs GCC 15.2.0 r7 UCRT/POSIX, Ninja 1.13.2, Python 3.14.2; relinker-only builds with
BUILD_TESTING=ON.3a416dd952merged with main25648aa121in a separate checkout (8b378bd976). Fresh configure and full build passed without compiler warnings. Serial CTest completed in 304.53 s: 203 passed, 0 failed, 1 skipped out of 204. No concurrent build/test job was started.windows_dependency_diagnostics,guest_module_identityandwindows_import_modulesall passed in this run.The entry stub allocated past the RVA limit before rejecting it. Moving the endpoint check afterresizealso fails with that message. Restoring the guard passes, including the high-RVA control. Debug with_GLIBCXX_ASSERTIONSpassesentry_stubandwindows_entry_stub_bounds, 2/2. Both new source files pass-Wall -Wextra -Wpedantic -Werrorsyntax checks.8c1c8a24b8fb57d62a2ea0b06ab9551d848e1f1f5fa4e9828b4edb7c40b7783f.36eeec6bb5is based on main8a526d4495. Compared with the fully tested integration,core/relinker, root CMake,cmake,toolsand the build workflow are unchanged. The exact rebased commit has not received another full suite run. Conventions and whitespace checks pass.Earlier, on base
017f2151ca, a parallel 204-test run that overlapped a Debug build had 200 passes, three timeouts and one skip. The three tests named above then passed serially on both unchanged main and the fix, and passed again in the fresh full serial run. The cause of the parallel failures remains unestablished, so parallel CI stability is not claimed.long_pathsskips because this host'sLongPathsEnabledis not 1. No Windows or antivirus settings were changed. Linux/macOS execution and upstream build checks remain pending. No full runtime, title, GPU, performance or exhaustive PE-validation claim is made; the vector-capacity branch was inspected, not forced through an impractically large public input.Overlap review: the required
tools/pr_overlap.pyrun completed serially after refreshing a partial-clone object fetch. It reported the expected overlap with included #6204. The shared-file diffs it could not compare were inspected for #2780, #5021, #5138, #6044, #6802, #6879, #6977, #7173, #7332, #7450, #7531 and #7594; #6586 was inspected when the bot subsequently added it. They add other sources/tests or change test registration. #6044 would require adapting the new registration if itsadd_component_testconversion lands first. #7594 changes MXCSR handling around the guest entry call, away from the allocation guard. #6586 adds a separateguest_zero_initializerregistration. No additional prerequisite was identified; no combined runtime result is claimed.Checklist
main; no other open PR implements the same functions (own test-only follow-up; #6204 is the included prerequisite)NotImplemented_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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T12:35:03Z.
Review: APPROVED
Reviewed — looks good
The allocation guard and its runtime boundary test are consistent with the described goal at head
36eeec6bb5e421a3d705469af90398dc87749830; no blocking defect was verified.What I ran
No build or tests were run. I read the prepared diff and changed-file texts, then inspected
CheckedRvato confirm the tested error condition.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read all four files listed in
manifest.json:core/relinker/CMakeLists.txt,core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp,core/relinker/elfpatcher/tests/WindowsEntryStubAllocation.cpp, andcore/relinker/elfpatcher/tests/WindowsEntryStubBoundsTests.cpp. I also readcore/relinker/elfpatcher/src/windows/WindowsPeFormat.cppfor theCheckedRvabehavior. No excluded changed files were listed. Builds, tests, Windows runtime behavior, and Linux/macOS execution were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by catminou4 on 2026-11-25T06:20:24Z.
Review: COMMENTED
This change is already in
main: merging the branch into currentmain(3cab484efb) leaves no diff.mainhasWindowsEntryStubBuilder.cpp's bounds check frome8ade52d79and the samewindows_entry_stub_bounds_teststarget from7482a5a700.On that merge, on Linux x86_64 (relinker-only Release build, GCC),
ctest -R '^(windows_entry_stub_bounds|entry_stub)$'passes.Nothing left to merge; this can be closed as superseded.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:48:18Z.
Review: COMMENTED
The exact branch passed the Windows entry-stub bounds CTest in a Linux relinker-only build.
AI-assisted: yes.
Pull request closed