Repository navigation
Description
Context
The Kyty shader recompiler has a libFuzzer target, kyty_shader_recompiler_fuzzer. With KYTY_FUZZ_SPIRV set, its harness runs spirv-val (Vulkan 1.3) on every module the recompiler produces. Earlier rounds found decoder over-reads, a use after free and several kinds of invalid SPIR-V, all fixed and locked by kyty_shim_recompiler_robustness and kyty_shim_recompiler_valid_spirv. Two kinds of invalid modules are still produced:
- a call graph that the execution model does not allow (
spirv-val: "callgraph contains function … which cannot be used with the current execution model"); - atomic operations (
OpAtomicLoad,OpAtomicUMin,OpAtomicUMax) on a storage class that Vulkan does not allow for them (VUID-StandaloneSpirv-None-…), seen on vertex, compute and pixel shaders.
A driver may crash or miscompile on an invalid module, so the recompiler must either produce a valid one or refuse the shader with a clear reason.
How to reproduce
Linux, with the Kyty core's Clang and AddressSanitizer:
cmake -S . -B build-fuzz -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON \
-DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 \
-DANYPS5_ENABLE_ASAN=ON -DANYPS5_KYTY_FUZZERS=ON
cmake --build build-fuzz --target kyty_shader_recompiler_fuzzer
mkdir -p corpus invalid
KYTY_FUZZ_SPIRV=log KYTY_FUZZ_SPIRV_DIR=invalid ASAN_OPTIONS=detect_leaks=0 \
"$(find build-fuzz -name kyty_shader_recompiler_fuzzer -type f | head -1)" corpus -max_total_time=3600Each distinct refused module is written as invalid/invalid-<n>.bin (a 4-byte header, then the shader words, little-endian). The fuzzer works from an empty corpus; never commit inputs taken from a game's shaders.
What to do
For each kind: find the pass or emitter that produces it, fix it or refuse the shader with a reason (as KytyFuzz::Run reports for the existing refusals), and add a minimal hand-written case to KytyShim/tests/RecompilerRobustness.cpp, as for the five refusal cases there.
Acceptance
- The new cases pass, and
kyty_shim_recompiler_valid_spirv(which reruns every case withKYTY_FUZZ_SPIRV=abort) passes. - One hour of fuzzing finds neither kind again.
Size
Medium; one pull request per kind.
Activity
relativespace2K commentedon Nov 24, 2026
Implemented the atomic storage-class kind: LDS atomics in a stage without workgroup storage are lowered to a load, the operation and a store (the LDS variable is per invocation there), so the module no longer contains OpAtomic* on Function/Private. Workgroup and storage-buffer LDS keep their atomics. The new ds_add_u32 pixel and ds_min_u32 vertex cases pass under KYTY_FUZZ_SPIRV=abort; kyty_shim_recompiler_valid_spirv passes. The call-graph kind is still open. PR: #291
fix(kyty): lower LDS atomics on private storage to a load and store