fix(windows): enter guest startup on an arena-backed main stack #3965
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3965"
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 eliasbruno124-dev on 2026-10-11T20:00:47Z.
What
Enter Windows guest initialization and the ELF entry on a committed GuestArena stack. Native module loading stays on the host stack, preserving #679's low native-stack policy and its protection against fragmenting fixed guest mappings.
In the retained TLOU Part II Remastered PPSA15508/01.002.000 comparison, the allocator rounds the stack address down to a 1 GiB boundary and compares it with an initialized zero field. The low host stack also rounds to zero, selecting an uninitialized allocator and dereferencing null at original VA
0x1b60f2. With the guest stack, that allocation returns a valid pointer and the title goes on.The libc helper preserves the thread and TLS, updates Windows stack bounds and enters a fresh unwind root. It uses the native reservation's capacity plus a 64 KiB inaccessible bottom region and keeps the stack alive through shutdown. Setup failures clean up on the original stack; missing helper exports fail explicitly. Console stack placement, capacity and accounting remain unmeasured and are recorded in the libc technical debt.
EnterGuestMainStack_nid_no_patchnow has one signature on both systems. #7532, merged on 2026-11-03, added the Linux helper to libkernel asAPS5_VABI (void* arguments, void (APS5_VABI* entry)(void*)), andGuestModuleArgsHost.cpp, the stand-in several relinker tests install aslibc.prx, defines it that way. This branch had a one-argument Microsoft-convention export of the same name in libc, which the Windows entry stub called with the entry inrcx; against the stand-in that call jumped to whateverrsiheld, which is theguest_zero_finalizercrash Superseabas and BunnyFl reported and relativespace2K traced. The libc export now takes the same two arguments in the same convention and handsargumentsto the entry inrdi; the stub passes a null argument block and the entry inrsi(xor edi, edi; lea rsi, [rip+entry]; call rax). The stand-in is unchanged. Windows still resolves the helper fromlibc.prx, the library every Windows conversion loads, while Linux resolves it fromlibkernel.prx; the libkernel implementation is compiled for Linux only.The kernel-variant import fixtures install the runtime image as host
libc.prx, so that image must export the guest-main-stack entry helper. The maintainer's fixture correction is preserved.Merge order: #6540 and #10157 have merged, #7135 was closed unmerged on 2026-11-08. The main-thread exit integration still depends on corrected #7149, which is open and conflicts with
main; this branch does not resolve that. #7594 adds MXCSR initialization at the same startup area, a separate operation.Tested
Current head
bc0ee29e4c: the four earlier commits rebased ontomain439f320158without conflicts, authors preserved, plusfix(windows): match the Linux guest main-stack entry signature. Windows 11 Pro 10.0.26300, MSYS2 UCRT64 GCC 16.2.0-6, Release, full build, nothing else merged.main439f320158built the same way;guest_zero_finalizeris among them.windows_guest_main_stack,windows_guest_main_stack_failure,windows_guest_main_stack_entry,guest_zero_finalizer,guest_module_args,windows_import_modules,windows_trace_imports,windows_kernel_variant_sys,windows_kernel_variant_web,entry_stub,windows_entry_stub_bounds,guest_kernel_is_stackandguest_pthread_stackpass in 3 of 3 runs.WindowsGuestMainStack.cppnow also checks that the argument pointer reaches the entry.public_headerschecks andlinux_guest_stackpass, as onmain.WindowsEntryStubBuilder.cpptaken from the previous commit (entry inrcx) and only the relinker rebuilt,guest_zero_finalizer,windows_guest_main_stack_entry,windows_import_modules,windows_trace_importsand bothwindows_kernel_varianttests fail; restoring the file makes all 13 pass again.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.--windows --to-intel --registry --module-dir .), NVIDIA GeForce RTX 3060 Laptop GPU, no input: runs for the 100 s limit at 600 presents per 10 s (median frame time 16.7 ms), and the dumped frames show the title's picture.main439f320158, built and converted the same way, does the same (600 presents per 10 s from second 20 on in both runs). The convertedapp.execontains the helper's name; the one made by a relinker without this change does not._WIN32blocks, the Windows entry stub builder and Windows-only tests, except the one-byte fixture change intest_windows_import_modules.py, whose converted programs run only on Windows.Earlier evidence, from heads before the signature change:
8029f87e58merged onto latermaincommits, and they passed; Superseabas, BunnyFl and relativespace2K foundguest_zero_finalizerfailing in those merges. XairRrR ran the tests registered on Linux.6239ceffcand this PR atf49abbed2merged onto it, the PR alone. The maintainer accepted it as the requested independent title comparison.main0aa4cb1cversus this PR alone at4387c499: both runs reached the same abort at the time; at original entry RSP changed from0x60fec8to0x20021ff48, with Windows stack bounds0x200010000..0x200220000.main39bac5d055with #18086, #18116, #11630 and #17570: without this PR the run ends with a null read atapp.exe+0x1c60f2; with8029f87e58merged it continues to an assertion on the second keyboard port after 46 s, and with #18119 added it runs for the 200 s limit. Not repeated on the current head.a11c8f7fwith #3713, #3509, #3897 and #3925: only the main-stack entry and libc differed between the run that dereferenced null and the run that mountedcore.psarcandcommon.psarc.No other open PR found that implements this Windows main-stack transition; #7532 is the merged Linux counterpart. No menu, gameplay or frame-time claim.
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)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:19:49Z.
Could you run a Windows title that already boots on main with this PR alone and post where it gets to before and after? Every title's main thread moves to the new stack, and the only title run so far is PPSA15508 on an integration branch with #3897 and #3925.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T10:11:33Z.
Review: DISMISSED
This changes the startup path of every Windows executable (the main thread moves to a GuestArena stack), and the only run so far is PPSA15508 on an integration branch that includes #3897 and #3925. Before this can merge:
mainwith this PR alone and post where it gets to before and after. We can't run titles or Windows here, and the new tests only exist underif(WIN32).main: it conflicts incore/libs/prx/libc/CMakeLists.txt(test block) anddocs/dev/TechnicalDebt.md(line 395, adjacent to other entries).Once both are done we can look at it again; the code itself needs no other change from what I read.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T13:41:05Z.
Resident Evil Village (PPSA01556, 01.210.000) needs this. On a local branch past its earlier stops, about 30 s in, it asks
sceKernelIsStackfor its main thread's stack and protects the whole range with CPU read/write. Without this PR, that call aborts:That range is the host stack the relinker reserves in the PE header (0x210000). Windows commits it on demand, so below the guard page it is only reserved. On the console the whole main stack is mapped.
I checked this PR with a test that does what the title does: enter
EnterGuestMainStack_nid_no_patch, callsceKernelIsStack, protect the whole range with 0xc2, then write to its lowest page. With this PR'sGuestStackschange it passes, because the stack is arena memory and the arena path commits its lowest 64 KiB placeholder. Setup: Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 3070 Laptop.Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-13T21:33:08Z.
Rebased onto
0aa4cb1cand resolved the libc test block, startup diagnostic and debt conflicts. At4387c499, the full runtime build, nine focused stack/context tests and all 121 relinker tests pass on Windows 11 with WinLibs GCC 15.2.0 r7. The upstream tracing fixture needed the main-stack helper; its assertions and the explicit missing-helper regression remain intact. CTest ran noninteractively with unchanged timeouts.I also ran Castlevania Dominus Collection PPSA15645/01.003.000 on pure main versus this PR alone, without #3897/#3925 or other unmerged changes:
0aa4cb1c4387c4990x60fec80x20021ff48scePadUnknown_n3kSX62fgNo not implementedsceVideoOutSubmitFlipcallsThe candidate's Windows stack bounds are
0x200010000..0x200220000. Inputs, other runtime libraries and settings were identical, and actual loaded module paths were checked. Both used the same readable SELF-to-ELF staging with original relative filenames and same-name resource mappings; the original dump stayed unchanged. No input or return-value substitution was used.This supplies a main-versus-PR startup comparison through graphics initialization, but not a title reaching its menu on main. It does not establish gameplay or performance; the transfer running alongside the observations also rules out a clean performance comparison. The PR body distinguishes this run from the earlier TLOU integration evidence.
#4774 and #5406 add different operations at the same startup insertion point. Neither is stacked here; their merge order still needs coordination. The later main refresh at
8d98e8851merges cleanly with this branch and does not change these entry/stack functions.Prepared with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:19:57Z.
Rebased onto
main; the only conflict was thedocs/dev/debt/libc.mdentry next to the new Windows direct-memory one.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:35:27Z.
Thanks for the rebase and the Windows test run. adriadam10's review still needs one thing: a Windows title that boots on current
main, run with this PR alone, showing where it gets to before and after (title ID, GPU/OS). @EagleBearerYS, could you run Resident Evil Village on this head on top ofmain?Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T07:15:49Z.
Resident Evil Village (PPSA01556, 01.210.000) doesn't boot on plain current
mainon this PC, so both runs below add the same things tomain, spelled out. Same machine and base for both: RTX 3070 Laptop GPU (8 GB), driver 617.42, Windows 11 Home 10.0.26300,main0b6d033b8.mainprepares every shader at registration, and here that gave a black screen for 10 minutes (private memory at 21.9 GB, heading for the commit limit). Both runs add local commits that prepare each shader at its first draw instead (APS5_RE8_LAZY_PREPARE=1, withAPS5_NO_GPL=1). They don't touch memory mapping or stacks.mainalso aborts 19 s in since #5596 (a 419 MiB address-based copy; reported there, fix in #5688). Both runs raise that guard withAPS5_ADDRESS_COPY_MAX_MIB=512.Before (
mainplus the above, relinked withmain's relinker): it stops 93 s in, before the first dialog:That's the mprotect emulation's check for memory outside the guest arena (
DirectMemory.cpp:135). This run had no trace, so the failing range wasn't printed.After (the same plus this PR at 49b51d205, relinked with this PR's relinker, plus a local commit that only adds prints under
APS5_TRACE_MAIN_STACK=1): the main thread switches to the arena-backed stack as designed. Itsrsplands in the same guest stack range as in eliasbruno124-dev's Castlevania table (0x20021ff48 at entry):Village then stops 44 s in, also before the first dialog, on the same check, but for another thread's own host stack:
Thread 5340 isn't the main thread (18724). The range is its whole 0x210000 host stack allocation, outside the guest arena, protected read-write. Its lowest 0xd000 is still only reserved (
MEM_RESERVE), so the emulation throws.So this PR alone doesn't get Village past this check. With it, the main thread's stack is arena-backed, and the stop is on another thread's host stack.
Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-14T09:58:54Z.
Rebased the maintained
49b51d205head onto66f894761; the new head is147d1158b. The sole conflict was the shared import-test fixture. Both contribution commits and their runtime code are preserved.Windows validation passes: full packaged runtime/relinker build, 10 focused stack/runtime tests, 123 relinker tests, conventions and whitespace checks. The initial occupied-base test timed out under interactive Windows error handling; the unchanged test passes with CTest's
--interactive-debug-mode 0. No assertions or timeouts were relaxed; #5675 already addresses that test's dialog handling.The requested comparison with a title already booting on main remains open. This rebase adds no new title or gameplay evidence.
Prepared with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-14T18:50:57Z.
Rebased onto
ed835aa76after #5406 merged; the new head isf49abbed2. Both conflicts are resolved while preserving complete unresolved-import reporting and the fixture's two options. An unresolved import still fails before the main-stack transition. The contribution's runtime behavior and tracing-fixture correction are retained.Windows validation passes: full packaged runtime/relinker build, 10 focused stack/runtime tests, all 126 relinker tests, conventions and whitespace checks. CTest ran noninteractively with unchanged assertions and timeouts. The candidate also merges cleanly into
e27ff7c54.The requested comparison with a title already booting on current main remains open; this rebase adds no new title or gameplay evidence.
Prepared with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T01:46:43Z.
Windows run of this head alone, merged onto
main6239ceffc(clean merge; it also merges cleanly onto the newer2559e9623, not built).f49abbed2, base6239ceffc.libspass with 0 errors. There are no warnings in the files this PR touches; the only warning,-Wstringop-overreadin libSceAgcShaderFusion.cpp, is also onmain.--repeat until-fail:3, all 13 passed 3/3:windows_guest_main_stack,windows_guest_main_stack_failure,windows_guest_main_stack_entrywindows_import_modules,windows_trace_importsguest_kernel_is_stack,guest_kernel_stack_protect,guest_pthread_stack,guest_sigaltstack,guest_user_context,guest_user_context_exit,entry_stub,entry_point_boundsctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip'): 804/811. These six timed out while the host was busy with other builds and passed when rerun one at a time:conventions_ci_gate,debt_split,hardware_oracle_compare,check_compile,guest_raise_exception,windows_diagnostic_fixture_isolation.check_main_syncalso fails on plainmainhere: it expectssp ace é.txt, but the console code page printssp ace é.txt. On plainmainthe same suite gave 794/808, and every runtime failure passed when rerun alone.Titles: catalog homebrew, each relinked with that side's own relinker and libs. Each ran 60 s in a window (
ANYPS5_REQUIRE_DISPLAY=1,SDL_VIDEODRIVER=windows) with no input. The main thread's stack bounds were read from its TEB 10 s in.main6239ceffcTransferring control to ELF entry point, presents continuously, still running at 60 s, no stop lineccleste | FPS: 59.83 (3401),ccleste | FPS: 53.42 (3071)ccleste | FPS: 85.81 (4778),ccleste | FPS: 33.31 (2130)Swapchain created ... extent=1484x835 images=2, test screen shown, still running at 60 s, no stop lineScreenTester5 | FPS: 0.00 (2)(two runs)ScreenTester5 | FPS: 0.00 (2)0x410000..0x610000/0x400000(both titles, every run)0x200010000..0x200220000/0x200000000(both titles, every run)mainrun:wsi/videoout: 119.88 Hz accepted, but a vblank comes every 22.584 ms; 59.94 Hz restored.mainand 2130–4778 with the PR.arg=0000000200000150onmainandarg=0000000200220150with the PR.Verdict: on Windows the build, the tests above and the non-GPU suite pass. ccleste and ScreenTester5 reach the same point on
mainand with this PR alone, with no new stop, and the main thread runs on the arena-backed stack (0x200010000..0x200220000).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T00:03:22Z.
@adriadam10 your first point is covered now: screamm ran ccleste and ScreenTester5, which both boot on main, with this PR alone on main
6239ceffc(Windows 11, RTX 4070), and both behave the same before and after; only the main-thread stack moves into the arena. The head has only been rebased since then (the changed lines are identical tof49abbed2), and it merges cleanly with current main. Could you take another look?Imported from boykopovar/AnyPS5. Originally posted by Pouare514 on 2026-10-17T14:00:57Z.
Coordination evidence for this PR + #7149 (guest pthread/fiber stacks):
(a) Entry stub active: combo with old libs (pre-guest-stack) fails with GetLastError 127 on missing guest main-stack entry, confirming the new stub path is taken.
(b) Combo fixes TLOU NdJob allocator crash: 13 NdJobWorkerThreads on guest stacks (0x1404xxbc80), no 0x1a54d81 fault, Vulkan ready + swapchain 1472x828. The two halves are complementary, files disjoint, no duplication.
(c) Behavior change: new stub chdirs to exe dir while old stub preserved launch cwd, so layouts without local app0/sce_sys hit
param.json not found(AppMetadata ResolvePath/current_path). Consider documenting cwd requirement in USAGE.md or keeping cwd fallback.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T14:15:34Z.
Thanks for the coordination evidence. Review at 5247944b7: the entry path looks good. The second RUNTIME_FUNCTION gives a proper unwind root, it runs once, and cleanup happens on the original stack. It still merges cleanly with main and with #7149.
One item holds it, and the fix belongs in #7149. If the main thread calls
scePthreadExitwhile workers are running, Windows exits the thread through_endthreadex->ExitThreadwith the TEB still pointing at the guest arena stack. That's the same class as the #7149 blocker, and new with this PR, since today main exits from the host stack. Details and the suggested single fix inscePthreadExitare on #7149. Normal exit/ExitProcess is fine.On (c), the cwd change: this PR doesn't cause it. The stub's
SetCurrentDirectoryWto the exe dir is already on main (WindowsEntryStubBuilder.cpp) and at this PR's merge-base, and the diff doesn't touch it; the comparison was against pre-10-10 stubs/libs. A launch-cwd note in USAGE.md would be a separate change against main.Planned order: #6540 -> #7135 -> #7149 (fixed) -> #3965.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T21:54:45Z.
Review: APPROVED
Reads right. In
EnterGuestMainStack_nid_no_patch(core/libs/prx/libc/src/GuestStacks.cpp), the new stack copies the host main stack's reservation capacity above a 64 KiB inaccessible bottom, and the entry frame is set up for the Windows x64 convention.Rsp = top - 40with the 64 KiB-aligned top leavesrsp % 16 == 8at entry with 32 bytes of shadow space above a zero return address, andRbp = 0gives the unwinder a clean root. A failure during setup releases the reservation and clearsenteredbefore rethrowing, on the original stack. TheGuestArenaUnpinWritablein that path is safe when the commit failed before anything was pinned:WindowsMappings::Unpinonly decrements pages whosepinsis non-zero (core/libs/prx/libc/include/WindowsMappings.hpp).Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto current
main, after building thewindows_stdio_*fixture DLLs:windows_guest_main_stack,windows_guest_main_stack_entry,windows_guest_main_stack_failure, and the relinker tests this PR edits (windows_import_modules,windows_trace_imports,windows_kernel_variant_sys,windows_kernel_variant_web) pass, 7 of 7, nothing skipped. The four relinker tests also pass on plainmainwith the same fixtures.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T22:15:08Z.
Review: COMMENTED
Reviewed — comments
The merge is clean, the build succeeds, the convention checks pass and the relinker tests that are registered on Linux pass. The new main-stack switch and every test that exercises it are Windows-only, so this Linux machine could not test the behaviour. I found nothing blocking.
What I ran
Head
8029f87e5872277c330494a052a3d907052a3b7b,main9090972b7e91fd266819cbd77a8b058e177b5682, merged treeb944fb303a78e2f2d6db2ec234292c5b4501b05f. Machine: Debian 13 VM, GCC 14.2.0, Release, Ninja. The prepared build of the merged tree was used.Results
maingit diff --checkcheck_conventions.pyAll conventions checks passed.libsmain.guest_net_ctlwas skipped for a reason that is not expected, which also happens onmain.windows_import_modules,windows_trace_imports,entry_stub,windows_entry_stub_bounds,guest_kernel_is_stack,guest_pthread_stackwindows_guest_main_stack,windows_guest_main_stack_failure,windows_guest_main_stack_entry,windows_kernel_variant_*if(WIN32))Negative control
I restored
WindowsEntryStubBuilder.cppfrommainand rebuiltrelinker.windows_import_modulesandwindows_trace_importsstill passed, so the control does not detect the change on Linux. Those tests only run the converted executable underos.name == 'nt', which includes the new missing-helper assertion. Here they only check the conversion. The three new libc tests are Windows-only and were not built. After the control I restored the merged file and rebuilt.git status --porcelainis empty.BunnyFl's approval reports that the three new tests and the edited relinker tests pass on Windows on this head. screamm reported the same for an earlier head with identical changed lines. I could not reproduce either run.
Findings
Blocking
None.
Non-blocking
core/libs/prx/libc/src/GuestStacks.cpp:114commits the whole stack. Thencore/libs/prx/libc/src/GuestStacks.cpp:131setsStackLimitto its lowest committed byte, and the 64 KiB region below it isPAGE_NOACCESS, not aPAGE_GUARDpage.STATUS_ACCESS_VIOLATIONinstead ofSTATUS_STACK_OVERFLOW. Unlike the host stack, there is no reserved guard region left for the overflow handler. Both the host and the console abort in this case, so the effect is limited to diagnostics.docs/dev/debt/libc.md:141.docs/dev/debt/libc.md:141has no final period, unlike the entries around it.Review of the stub code: the second
RUNTIME_FUNCTIONreusesunwindRva. That is valid becausecore/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp:810emits the same prologue bytes as the main entry at:503. The stack slots[rsp+0x20..0x58]that the post-switch code reads are all written after the switch, at:859-875. The exception-table bound at:925is equivalent to the old>= 32check when there is one entry. The reserved table still holds 32 entries (:134). On the new stack,rsp = top - 40givesrsp % 16 == 8with a zero return address, as BunnyFl's review says.Not verified
windows_import_modules,windows_kernel_variant_sys/web, and the generated-ELF exit code (42 versus 89). This machine is Linux-only, and these paths are guarded byWIN32oros.name == 'nt'.scePthreadExitwith workers still running would exit with the TEB pointing at the guest arena stack. That fix belongs in #7149, so the merge order #7149 before #3965 matters. I did not check whether #7149 has merged.To get this to a good state
pr=3965) passeswindows_guest_main_stack,windows_guest_main_stack_failure,windows_guest_main_stack_entry,windows_import_modules,windows_trace_importsandwindows_kernel_variant_*.Depends online says.Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-05T16:22:44Z.
Review: COMMENTED
Windows run of head
8029f87e58merged onto currentmain4741457fed(clean merge, local only). It covers the Windows-only tests @XairRrR couldn't run, and it finds one regression against a test that was added after this branch's base.Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Python 3.13, Release,BUILD_TESTING=ON.The PR's Windows tests pass.
windows_guest_main_stack,windows_guest_main_stack_failure,windows_guest_main_stack_entry,windows_kernel_variant_sys,windows_kernel_variant_web,windows_import_modules,windows_trace_imports,entry_stub,windows_entry_stub_bounds,guest_kernel_is_stack,guest_pthread_stackandpublic_headerspass, 3 runs each.windows_guest_main_stack_entrypasses 3 of 3 from PowerShell; see thePATHnote below for Git Bash. Onmainthe 9 of them that exist pass.Regression:
guest_zero_finalizerfails on Windows with this PR.guest_zero_finalizermainAssertionError: ('windows', True, 3221225477, '', '', '')main'sWindowsEntryStubBuilder.cpp3221225477is0xC0000005. The converted program crashes before it records anything.zero,absentandnonzero. All three pass onmain, and the Linux cases pass on both.THREAD_POINTERprefix (tls=True), so it reads the thread pointer, and it's loaded fromsce_module.f5879c4ada(fix(relinker): preserve guest finalizers at address zero, 2026-10-24), which isn't in this branch, so it hasn't run against this change before.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), it is the only failure thatmaindoesn't also have on this machine: 4,199 of 4,205 pass. The other five are known:test_registrationandselect_tests_MissingCommandTests(#15652),windows_crash_thread_name(#15578),agc_driver_direct_write_completion(#15564) andagc_driver_quad_pixel_mask(#14341).Red check. The merged tree with only
WindowsEntryStubBuilder.cpptaken back frommainfailswindows_guest_main_stack_entryandwindows_import_modules, so the new tests do cover the stub change. With that one file back,guest_zero_finalizerpasses again.Overlap with #7532. Since this branch's base, #7532 (merged 2026-11-03) added
extern "C" EnterGuestMainStack_nid_no_patch(void* arguments, void (*entry)(void*))to libkernel (Pthread/src/Thread.cpp). It maps a main stack at the console's address range and isn't guarded to Linux. This PR adds a libcEnterGuestMainStack_nid_no_patch(void (*entry)())with the same name, a different signature, and an arena stack sized from the host stack. The Windows stub takes it fromlibc.prxwithGetProcAddress, so the two don't collide at load time, andpublic_headerspasses. Still, that leaves two main-stack implementations under one exported name in two libraries. Whether Windows should use #7532's would be worth settling here.Smaller:
test_windows_guest_main_stack.pycopies the compiler runtime DLLs from the first match onPATH.libstdc++-6.dllonPATHhere is Git for Windows' (C:\Program Files\Git\mingw64\bin, an older GCC). The converted program then fails withFailed to load module: ...\libc.prx,GetLastError: 127.CMAKE_CXX_COMPILER) would avoid that. The 3-of-3 results above are from the PowerShell environment.check_conventions.py --base mainpasses on the merge.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T17:33:17Z.
Review: CHANGES_REQUESTED
@eliasbruno124-dev changing my review to request changes:
guest_zero_finalizerfails with this PR on Windows. cc @Superseabas, who found it. You're right, and my approval at this head missed it: the test came in withf5879c4ada(2026-10-24), which isn't in this branch, and I didn't run it.I reproduced it. Head
8029f87e58merged ontomain6a337633c6(mergeba5963cf3b, clean), Windows 11 Pro 10.0.26300, WinLibs GCC, Release, one run of each:WindowsEntryStubBuilder.cpptaken frommainguest_zero_finalizerAssertionError: ('windows', True, 3221225477, '', '', '')windows_guest_main_stack_entrywindows_import_moduleswindows_guest_main_stack,windows_guest_main_stack_failure,windows_trace_imports,windows_kernel_variant_sys,windows_kernel_variant_web,entry_stub,windows_entry_stub_bounds3221225477is0xC0000005. So the change incore/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cppis what both the new tests and theguest_zero_finalizerresult turn on. I haven't looked into why the converted program crashes there, so I can't point at a line.Please merge
maininto the branch, which brings the test in, and makeguest_zero_finalizerpass on Windows with the stub change. I'll rerun these ten tests on the new head.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-12T10:31:27Z.
Review: APPROVED
@eliasbruno124-dev thanks:
bc0ee29e4cfixes what my change request asked for (the runs below), and I'm approving it. Thanks also to @relativespace2K for the trace that found the cause and @Superseabas for the original report.I reran the ten tests from my 2026-11-05 request plus
guest_module_args, on this head merged ontomain3b7f31fa70(merge6c11fc7412, clean), Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, withrelinker,guest_module_args_hostand bothwindows_guest_main_stack*executables rebuilt:WindowsEntryStubBuilder.cpptaken frommainguest_zero_finalizerwindows_guest_main_stack_entryAssertionError: (89, 'Transferring control to ELF entry point\n', '')windows_import_modulesAssertionError: (11, 'Transferring control to ELF entry point\n', '')guest_module_args,windows_guest_main_stack,windows_guest_main_stack_failure,windows_trace_imports,windows_kernel_variant_sys,windows_kernel_variant_web,entry_stub,windows_entry_stub_boundsSo 11 of 11 pass on the merge, none Not Run;
guest_zero_finalizer, which failed at8029f87e58with0xC0000005(my change request), passes now.The new commit reads as you describe:
EnterGuestMainStack_nid_no_patchincore/libs/prx/libc/src/GuestStacks.cppnow takes(void* arguments, void (APS5_VABI* entry)(void*))and putsargumentsinRdifor the entry, and the stub incore/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cppemitsxor edi, edi(31 ff) and loads the entry withlea rsi, [rip+...](48 8d 35) where it usedrcxbefore.Overlap:
tools/pr_overlap.py --branchon this head failed closed (exit 2). 50 open pull requests share a file but conflict withmain; the tool printed "cannot confirm overlap" for each. Most share onlycore/libs/prx/libc/CMakeLists.txtordocs/dev/debt/libc.md. Six share code this PR changes: #7149 and #9938 (GuestStacks.hpp/GuestStacks.cpp), and #11628, #11661, #11689 and #11698 (WindowsEntryStubBuilder.cpp). I searched those six patches' changed lines forEnterGuestMainStackand for the stub's entry-load bytes; none of them touches either. I did not compare the other 44 line by line.Not tested: Linux and macOS, a title, and the main-thread-exit case @oneandonlydean asked you about, which is yours to answer.
AI-assisted: yes (Claude Code)