AGC: since #5875, a registration library prebuild racing the window attach segfaults in LinkPipelineFromLibraries (Stray PPSA02100, warm shader cache) #6805
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 teepean on 2026-10-16T12:43:12Z.
What happens
On
main65d56a297(built with #6784 so that it compiles on Linux), Stray (PPSA02100) segfaults about 10 s after start, when the presenter attaches the window, on every run with a warm shader cache: 5 of 5 runs. The one run with a cold cache (first run after the shader cache version changed) survived. Builds on main332b0b1b7, before #5875, ran 13 warm runs of the same scene today without this crash. The code involved is unchanged on82ddae75b, the newestmainwhen filing (the line numbers below refer to it).Crashing thread (registration prepare pool), from the core dump:
At the same moment the VideoOut present loop is inside the attach:
The log's last lines are always the window device's constructor (
VulkanDevice constructor window=0x...,Presentation window context=... extent=1920x1080).Cause (from the code; consistent with the runs below)
Driver::AttachWindow(Execution/src/Driver/Presentation.cpp:44) callsdevice->PrepareForReplacement()on the windowless device (line 51) and keeps it inreplacedDevices.Graphics::ClearCachedPipelines(state->device)toVulkanDevice::PrepareForReplacement(Execution/src/VulkanDevice.cpp:2021, the call at 2036). Before #5875 the device's cached pipelines were cleared only at teardown.ClearCachedPipelinescallsClearPipelineLibraries(Graphics/src/PipelineLibrary.cpp:312), which destroys the device's library parts and erases its entry fromstore.devices(line 324).PrepareForReplacementcancels and waits for the journal replay first, but not for registration library prebuilds:PrebuildStageLibrary(Execution/src/Driver/Shaders/ShaderRegistry.cpp:879) queues jobs that hold the oldVulkanDeviceand build its parts throughLinkPipelineFromLibraries.LinkPipelineFromLibrariestakesauto& device = store.devices[context.device](PipelineLibrary.cpp:112) and thedevice.parts[part]map understore.mutex, then releases the mutex aroundvkCreateGraphicsPipelines(line 208). WhenClearPipelineLibrarieserases the entry meanwhile, the job relocks and searches a destroyed map (cache.find, line 219): the crash in frame #0. Its part would also be built on a device whose libraries were just destroyed.A fix would make
PrepareForReplacementwait for (or cancel) the registration prebuild jobs of that device beforeClearCachedPipelines, as it does for the journal replay, or haveClearPipelineLibrarieswait until no build for the device is in flight.Runs (same machine, same scene, stock game config)
332b0b1b7(before #5875), plus in 9 of them local DrawPipeline-only changes65d56a297+ #678465d56a297+ #678465d56a297+ #6784 + #6782 + #6771APS5_NO_PIPELINE_JOURNAL=1APS5_NO_LIBRARY_PREBUILD=1So the journal replay itself is not needed for the crash, and turning the library prebuild off avoids it. With the prebuild off, the replay loaded and built all 438 journaled pipelines (366 graphics, 72 compute) in 340 ms on 16 threads.
Every run also carries one local test switch (
APS5_NO_IDLE_STORE=1, which turns off the idle store; without it Stray hits an unrelated startup crash).APS5_PROFILE_DRAW=1was set in the runs on65d56a297, not in the 13 runs on332b0b1b7.Workaround:
APS5_NO_LIBRARY_PREBUILD=1.Tested on
Core dumps and logs are available on request.
AI-assisted: yes (analysis and text written with Claude Code; the runs and core dumps are from my machine).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T04:01:33Z.
Yes, please post the 43-line diff. The measurements show a useful attach-time improvement, but I would want to inspect the late-submission window before replacing the global drain: a
RegisteredPreparationcan still hold the retiring device and submit a prebuild after the device-scoped queue cancellation returns. A focused regression should coordinate an in-flight registration preparation with replacement and prove the old device cannot receive a prebuild after its teardown boundary.Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-17T04:30:03Z.
A second title with the same crash: High on Life (PPSA15388), Linux, RTX 4090, GCC 16.2.1, Release.
Same top frame (
std::_Rb_tree<std::vector<std::byte>, … VkPipeline_T*>::findinlibSceAgcDriver.prx), same moment: the last log lines areVulkanDevice constructor window=…andPresentation window context=… extent=1920x1080, then SIGSEGV about 25 s after start.main5d9dcc42d(before #5875) + PlayGo settingmainf26eb67c8+ PlayGo setting (now #6236)5d9dcc42dfindfindmain07e7414815d9dcc42dfindSo it matches what you found on Stray: any warm cache, not a cache from an older build, and a cold start survives. Pointing
ANYPS5_SHADER_CACHE_DIRat an empty folder is a workaround until the fix lands. I can run the fix on this title as soon as there's a branch.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-17T04:38:17Z.
A third title: Guardians of the Galaxy (PPSA01748), Linux, RTX 4090, GCC 16.2.1, Release.
Same top frame (
std::_Rb_tree<std::vector<std::byte>, … VkPipeline_T*>::findinlibSceAgcDriver.prx), same moment: right afterVulkanDevice constructor window=…andPresentation window context=… extent=1920x1080.mainf26eb67c8find; 1 reached the menuSo it's timing-dependent, as expected for a race. This title seems to hit it a little less often than High on Life (4 of 4), possibly because fewer of its shaders are prepared at registration.
Tested and written by Claude (AI assistant) on a contributor's machine.