Demon's Souls crashes 14 s after launch with a guest null read when built with ANYPS5_ENABLE_SPIRV_TOOLS=OFF (the default) #2552
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 fisherjoey on 2026-10-10T05:03:16Z.
With the default CMake option
ANYPS5_ENABLE_SPIRV_TOOLS=OFF, Demon's Souls (PPSA01341 v1.07) segfaults in its own code 13 to 14 s after launch, before any window opens. When I build the same commit with the option ON and change nothing else, it gets past that point and runs to 85 to 88 s, where it stops on the SPIR-V validation failure from #1921.I first took this for a regression on
mainbetweenae91d978and8b393b6e, and said so in #1283. That was wrong. My older good run used a build tree configured with ON, and my newer bad run used one configured with OFF. Built the same way, both ends behave the same.Results
All runs use
main+ #861 (#861 is needed on Linux, otherwise it crashes at 4 s with the guest arena outside the PS5 window). Same run directory, noAPS5_*environment variables, 90 s per run.ae91d978)segfault at 27a301718 ... error 4 in app.elf[83f96c]segfault at 27a30171c ... in app.elf[83f96c]SPIR-V validation before optimization failed(#1921)8b393b6e+ #861segfault at 20 ... in app.elf[8b5596](2 of 3 runs, the third atapp.elf[83f96c])8b393b6e+ #861, empty shader cachesegfault at 1050 ... in app.elf[83fb40]8b393b6e+ #861The only difference between the OFF and ON builds of 3c54adf0 is the flag. I flipped
ANYPS5_ENABLE_SPIRV_TOOLSin the same build directory and rebuilt. The fault address changes from run to run (0x10, 0x20, 0x1050, 0x27a3017xx), but it is always one of three read sites in the title's code (app.elfoffsets 0x8b5596, 0x83f96c, 0x83fb40). Nothing is logged on the host side. The last host line before the crash is the shader disk cache opening. The ON build also logs the Vulkan pipeline cache loading, and after that the shader disk cache reports hits and writes every 10 s. The OFF build logs neither.What I think is going on (not verified)
With the flag OFF,
Recompiler.cppskipsValidateAndOptimizeSpirveverywhere: after emission, on the vertex input specializations, and twice inbuildSpecializedModule. So the driver gets unoptimized SPIR-V that was never validated. My guess is that a shader the title runs during startup computes something different when it isn't optimized, and the game then reads a bad pointer out of the result. I haven't found which shader it is.Whatever the cause, two things stand out:
CMakeLists.txtdefaults the option to OFF, but the CI configure step inbuild.ymlpasses ON. So a default local build runs different shader code from what CI tests.Setup
main8b393b6eandae91d978(#861's base), each with #861 3c54adf0sce_module(libc, libSceNpCppWebApi)I can narrow down the shader if that helps, for example by turning validation and optimization on for one stage at a time.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T11:24:37Z.
Separating SPIR-V validation from optimization
I traced the current
mainimplementation atb5f5362d. One detail may help make the ON/OFF comparison more diagnostic: the existingAPS5_SPIRV_OPT=noneswitch does not bypass optimization for every specialized module.Recompiler.cppcallsValidateAndOptimizeSpirv(..., !embedded); ordinary modules are optimized.buildSpecializedModulecalls it withoptimize=true, specialize=true. InSpirvOptimizer.cpp, thenoneearly return is guarded by!specialize, so this path still runs optimization.optimize=false, so it validates but does not optimize.Sources: normal emission and validation, specialized module path, and the optimizer's
noneguard.For a clean diagnostic, a temporary build with SPIRV-Tools enabled could return the original module immediately after
tools.Validate(...)succeeds for everyoptimize=truecall, bypassing optimization while retaining validation. Comparing that run with normal ON and OFF builds, from the same source and equivalent empty shader caches, would separate validation from optimizer effects even when startup uses specialized pipelines.This is static source-path analysis; I did not run PPSA01341 or test the GPU behavior here.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-11T02:12:04Z.
@MarcZX100 thanks for the suggestion. I ran it.
Setup: one source tree for every variant, current
mainb5f5362d(#861 is merged now). On top of that, a local-only diagnostic: withAPS5_DIAG_VALIDATE_ONLY=1,ValidateAndOptimizeSpirvreturns the module right aftertools.Validate(...)succeeds, on every path including the specialized one. So validation still runs and the optimizer is skipped everywhere. The ON and ON+validate-only rows are the same binary, with and without that variable. Every run started from an empty shader cache. Same Demon's Souls relink and run directory for all, no otherAPS5_*variables.segfault at 6d980 ... in app.elf[83f9cf]at ~59 ssegfault at 2363c0 ... in app.elf[83f9cf]at ~109 sShorter 90 s runs earlier on the same source agree (those used an
app.elffrom the8b393b6erelinker; the table rows use one from the currentmainrelinker,78aedb40, since theb5f5362drelinker stops onsce_sys/about/right.sprx). OFF crashed twice in the same guest code (app.elf[83f9cf]and[83fb40], at ~64 s and ~68 s) after loading the debug menu files. ON and validate-only didn't get that far in 90 s.What this shows:
On current
mainthe OFF crash comes later than it did on8b393b6e(about 60 s instead of 14 s, after the window opens), in the same stretch of guest code:app.elf0x83f9cf, next to the 0x83f96c and 0x83fb40 sites from the first post.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by mcsilva-dev on 2026-10-11T15:45:56Z.
Possibly related, from a different angle: on Windows with PPSA01342 v1.005 (built with SPIR-V tools ON), I traced the start-up crash to the Acm module (0x10b) being reported as loaded while libSceAcm is still a no-op. The game has its own fallback when that load fails, and forcing it to fail makes the crash go away. After that the game hangs on a black screen with every BPE job worker spinning in the scheduler, at addresses close to the ones in this issue.
Details, addresses and what I ruled out are in #3710, in case it helps narrow this one down.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-11T16:41:43Z.
@mcsilva-dev thanks, that's a good lead. Our Linux logs for PPSA01341 v1.07 show the same call before the crash:
sceSysmoduleLoadModule unknown id: 267right after the title opens/app0/sound/distmodel.dml. So the US build takes the Acm path too. I haven't yet checked whether making the 0x10b load fail removes our crash at app.elf 0x83f9cf / 0x83fb40. I'll run that when the test machine is free and post the result here and in #3710.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-12T00:04:37Z.
Follow-up with the Acm lead from #3710, on PPSA01341 v1.07 (Linux, RTX 5070 Ti, NVIDIA 595.91.07).
Setup: current
mainbab7b328plus a local-only switch. WithAPS5_DIAG_ACM_UNAVAILABLE=1,sceSysmoduleLoadModule(0x10b)returns an error andsceSysmoduleIsLoaded(0x10b)reports it unloaded, as in #3710. Without the variable the binary behaves likemain. Same run directory and the same relinkedapp.elffor every run, 180 s each.main(load returns 0)DB_RENDER_CONTROL depth copy, resummarize or decompress is unsupported (register 0x0 = 0x00000010)Finished Initialization, nothing presented, frozen until the 180 s limitmainDB_RENDER_CONTROLerrormainanymore, with or without the Acm change. I checked that it isn't my machine: theb5f5362dOFF libs still crash atapp.elf[83fb40]today (about 68 s). Swapping the parts,b5f5362dlibs with the newerapp.elfcrash, andbab7b328libs with the olderapp.elfdon't. So a host-library change somewhere betweenb5f5362dandbab7b328(576 merges) fixed it. I haven't bisected that range.app+0x83bb9dandapp+0x83bb51), and nothing else makes progress. That looks like the black screen with spinning job workers described in #3710, but here it happens before initialization finishes.mainis theDB_RENDER_CONTROLdepth copy error above. Open PR #4049 looks aimed at it. I haven't tested it.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-12T00:05:04Z.
Closing: on
mainbab7b328the t+14 / t+59 guest null read no longer happens for PPSA01341 on Linux, with SPIR-V tools ON or OFF (details in the comment above). The fix is on the host-library side somewhere in b5f5362d..bab7b328; I haven't bisected it. The next stop,DB_RENDER_CONTROL depth copy, resummarize or decompress is unsupported, is a separate issue.AI-assisted: yes