shaders: validate disassembly listing completeness and report refused shader names (DISASM-VALIDATE-COMPLETE) #2646
Closed
leonida/mandy
matinsanei wants to merge 0 commits from
fix/shaders-disasm-validate-complete into main
pull from: fix/shaders-disasm-validate-complete
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!2646
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/shaders-disasm-validate-complete"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Resolves #2539.
Covers coordination item
DISASM-VALIDATE-COMPLETE.Summary
When building with parallel jobs, an interrupted disassembler or pipe truncation could leave incomplete disassembly files in
<work>/shaders/dxbc/disasm/. Previously:tools/shader_disasm.pydid not check whether the disassembly listing was completely written before publishing withos.replace.--skip-existingandmake_game.py'sdisassembly_listings(dxbc)only verifiedst_size > 0, thus treating truncated.sfiles as valid.ERROR: shaders: the translation index holds 26502 of the 26503 carved shaders (1 branch without encoding)(#2539).tools/rdna2spirv.pyonly tallied reason counts inwhy, omitting the names of the failing shaders, making it difficult to locate which shader among thousands was refused.Changes
tools/shader_disasm.py:is_complete_listing()checking that.sfiles end with a newline and contains_endpgm(optionally attempting Python fallback before publishing).--skip-existingre-disassembles incomplete listings instead of skipping them.make_game.py:disassembly_listings()now usesis_complete_disassembly_listing(). Truncated or incomplete files are excluded, triggering automatic repair indisassembly_statusbefore translation.tools/rdna2spirv.py:1 branch without encoding (@ped_standard_...)).test_is_complete_listing_rejects_truncated_listingsintests/test_shader_disasm.py.test_finished_disassembly_repairs_a_truncated_listingintests/test_shader_stage_resume.py.Verification
python -m unittest tests/test_shader_disasm.py(35 tests OK)python -m unittest tests/test_shader_stage_resume.py(48 tests OK)python -I tests/test_text_write_line_endings.py(3 tests OK)python -I scripts/check_no_game_data.py(clean)I reproduced a completeness gap at
00966ec84(GitHub merge7c9e340ed) with a four-instruction synthetic fixture. The three listed suites passed (35 disassembler tests, 48 resume tests, 3 line-ending tests).MEASURED. The fixture uses
s_cbranch_scc1 1,s_endpgm,s_branch 0, ands_endpgm. Real LLVM 23.1.5 decoded the full range and the result translated and passedspirv-val. Cutting immediately after the firsts_endpgm, or keeping the laters_branch 0without its encoding and ending the line, leaves an incomplete listing. Both completeness checks accepted both cuts.--skip-existingreturnedreused: 1and left the file unchanged in each case. Translation refusedbranch target outside codeand produced zero valid modules.MEASURED, fresh publication. A zero-exit mock LLVM returned that same three-instruction stdout prefix without a trailing newline. With empty stderr, the Python fallback repaired it and the shader passed
spirv-val. Adding only a message on stderr made the current producer publish the incomplete listing asclean: 1. The diagnostic footer supplied the newline, the firsts_endpgmsupplied the token, and translation again produced zero valid modules.Checking the decoder output before appending diagnostics would close the second path. The cache check also needs evidence that decoding reached the expected end of the code range, since a cut just after an earlier real
s_endpgmcan end on a complete instruction and line. Cache check · Publication orderSynthetic fixture only. AI-assisted with OpenAI Codex.
Thanks for the thorough reproduction and review! Both gaps are fixed in
aba6c9a06:tools/shader_disasm.py):one()now validates the decoder'sasmoutput withis_complete_asm(asm, expected_bytes=end - start)before writing the file or appending the; --- llvm-mc messages ---footer, sostderroutput can no longer mask a truncatedasmor missing trailing newline.tools/shader_disasm.py,make_game.py):is_complete_listing()andis_complete_disassembly_listing()now parse thecode 0x...0x...range from the header and verify that the total decoded bytes from; encoding: [...]and.longentries match the expected range length (catching cuts after an earliers_endpgmor lines missing encodings), while ignoring the; --- llvm-mc messages ---footer.Added regression tests in
tests/test_shader_disasm.pycovering all three cases (cut after an earliers_endpgm, missing; encoding:, and truncatedasmwith anllvm-mcstderr footer).Verified locally:
python3 -m unittest tests/test_shader_disasm.py tests/test_shader_stage_resume.py tests/test_text_write_line_endings.py(86 tests OK)Thanks for following up. On exact
aba6c9a06(GitHub mergeeba99aa70), all three damaged listings from the earlier probe were repaired on resume, including the cut after the firsts_endpgmand the newline-terminated branch without an encoding. The mock LLVM stdout/stderr case also fell back to a complete listing. Each output translated and passedspirv-val. The three focused suites passed again (86 tests).MEASURED, new regression with real LLVM 23.1.5. A hand-made 12-byte program has
s_branch 1, one unreachable0xffffffffdword, ands_endpgm. LLVM prints the two valid instructions (8 encoded bytes) and the warning for the skipped dword at input line 2. Onmain060c47160, the listing keeps that warning, translates 1/1 withspirv-val, and is reused. The PR treats the same 8 encoded bytes as truncated, uses the Python fallback, and publishes a listing without the LLVM warning. The resulting translation refusess_endpgmat0x12c, producing 0/1 valid modules, and--skip-existingregenerates it on every run.Control. The PR translator still produces 1/1 valid modules when handed the original LLVM listing directly. Both new cache checks reject that known-good listing. Counting the explicitly skipped, in-range words from
invalid_offsets(err)alongside the encoding coverage would preserve the complete LLVM output and the offsets the translator needs. Completeness check · Existing warning-offset parserSynthetic fixture only. AI-assisted with OpenAI Codex.
Good catch! Fixed in
6b9768b2e:is_complete_asm(),is_complete_listing(), andis_complete_disassembly_listing()now count the explicitly skipped, in-range 4-byte words parsed frominvalid_offsets(err)(and the; --- llvm-mc messages ---footer) alongside the; encoding: [...]/.longbyte coverage.tests/test_shader_disasm.pyfor a 12-byte listing with a skipped invalid dword in thellvm-mcstderr footer.Verified locally:
python3 -m unittest tests/test_shader_disasm.py tests/test_shader_stage_resume.py tests/test_text_write_line_endings.py(86 tests OK)Confirmed on
6b9768b2e(GitHub mergeb3133c8c2onto32b9f4a3e) with LLVM 23.1.5. The default LLVM path now produces a listing and validated SPIR-V byte-identical to main's for the skipped-word fixture. The<stdin>:2:1warning is preserved,--skip-existingreportsreused: 1, and the make_game stage also counts the listing as complete.The three truncation cases and the mock decoder with the warning footer still regenerate clean output and pass
spirv-val. The three focused suites passed 86/86. Synthetic fixtures only. AI-assisted with OpenAI Codex.Verified on
main452d1d1b6(Windows, Python 3.13), and there is a decision to make before merging it.It applies and works:
The idea is the one the title says:
is_complete_asm()intools/shader_disasm.pychecks that a listing ends with a newline, containss_endpgm, and covers the byte range, and the caller retries or reports instead of continuing with half a listing.The decision: #2553 ("reject and retry truncated disassembly listing") is a second, independent solution to the same problem, and the two overlap on four files:
is_complete_asm(asm, expected_bytes, skipped_bytes)- a predicate, in placelisting_is_complete/listing_file_is_completefrom a newtools/shader_stage_manifest.py, plusTRUNCATED_RETRY_ATTEMPTS = 3, a failure journal and a lockmake_game.py,tools/rdna2spirv.py,tools/shader_disasm.py,tests/test_shader_disasm.py,tests/test_shader_stage_resume.pySo they are not duplicates - they are two designs for one fix - and merging both would mean two retry mechanisms and a conflict in the five shared files. One of them should be chosen and the other closed, rather than merged in sequence.
Which one is a maintainer's call. What I can add: #2646's is the smaller change (205 lines, no new module, no threading), #2553's keeps a manifest with per-stage completion state and retries at the stage level. If the pipeline needs to resume across runs, #2553's manifest is the one that records that; if the failure only needs to be detected and retried in place, #2646 does it with a predicate.
Not tested: the title's real workload - a genuinely truncated listing produced by the driver - since no disassembly of the game's shaders is available here; the tests exercise the synthetic fixtures.
Written with an AI assistant.
I compared
6b9768b2and #2553aee75f00on452d1d1b6, with LLVM 23.1.5 and synthetic inputs. #2646 merged cleanly. #2553 has a conflict intests/test_make_game_dry_run.py, outside the code and tests exercised here. Every case below was repeated three times.s_endpgm. #2553 published and reused that prefix. #2646's fallback published the full 16-byte listing, byte-identical to the complete control.<stdin>:2:1diagnostic. With the Python backend, #2646 rejected the same input. After a simulated short LLVM response, #2646 returnedinvalid wordsand published the Python fallback, but both its own cache checker andmake_game.disassembly_listings()rejected the file. A real--skip-existingrun decoded it again.s_endpgmfrom0x130to0x12cin the parser. The fallback needs to carry the offsets through publication and reuse.disasm.donereusable when the directory also contains a truncated.sfile absent from the unpack index. Current main invalidates resume in that case. The translator's directory scan still visited the extra file. Checking observed stems before filtering incomplete listings would preserve that safeguard.Synthetic fixtures only. AI-assisted with OpenAI Codex.
Independent verification on this machine (Windows 11, Python 3.13.14), and the negative control bites.
1. It applies.
merge-treeclean; the three commits cherry-pick ontomain1d22590b9without a conflict. Five files,205 insertions(+), 7 deletions(-).2. Its tests pass:
3. The negative control fails on
main's tools - with the PR's tests andmake_game.py,tools/rdna2spirv.pyandtools/shader_disasm.pyreverted:So the completeness check and the truncation repair are both absent on
mainand present with the change.4. The wider surface it touches did not regress:
What I did not test: the real corpus. The change decides when a disassembly listing is "complete" and when a shader is refused, and the synthetic listings in the tests are the only evidence here; a run over the 26,503 translated shaders would say whether the new rule refuses anything that used to translate. On this machine that is the shaders stage, which needs the game files and
llvm-mc.Written with an AI assistant.
Independent check on Windows (not the author), at
3ee23637f.tests/test_shader_disasm.py: 35 passedtests/test_shader_stage_resume.py: 48 passedtests/test_make_game_empty_translation.py: 20 passedEnvironment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10, llvm-mc 21.1.8.
No failures in the disassembly completeness/resume paths this touches.
AI-assisted: yes (opencode).
Addressed the remaining points from your comparison in
3ee23637fanddc3acde5f:make_game.py):disassembly_listings()now returnsNoneif any.sfile indisasm/is incomplete (even if absent from the unpack index), preservingmain's resume invalidation safeguard.tools/rdna2_decode.py,tools/shader_disasm.py): Addeddisasm_bytes_with_diagnostics()so bothbackend="python"and the fallback emit<stdin>:<line>:1: warning: invalid instruction encodingdiagnostics for skipped invalid dwords, keeping the byte offsets intact forrdna2spirv.pyand cache reuse.Verified locally (
86tests OK acrosstest_shader_disasm.py,test_shader_stage_resume.py, andtest_text_write_line_endings.py).Closing this PR in favor of #2553, which is the original claim (
SHADERS-DISASM-TRUNCATED-CHECK) and the cleaner fix for#2539(truncated disassembly listings and unnamed shader refusals).Side-by-side comparison:
#2646special-cases test fixture strings ("completed listing"and"synthetic listing") directly inside production completeness checks (make_game.pyandtools/shader_disasm.py), whereas#2553updates the affected test fixtures directly.#2646duplicates completeness validation betweenmake_game.py(is_complete_disassembly_listing) andtools/shader_disasm.py(is_complete_listing/is_complete_asm), while#2553centralizeslisting_is_complete/listing_file_is_completeintools/shader_stage_manifest.py.#2646still requires"s_endpgm" in body(rejecting valid listings whose final instruction consumess_endpgmbytes as a literal) and invokesrdna2_decode.disasm_bytesfollowed immediately bydisasm_bytes_with_diagnostics(double-decoding) wheneverbad != 0.#2553validates full selected byte-range coverage (encoded_bytes + invalid_words * 4 == expected_bytes), handles trailing-literals_endpgm, validates observed vs. complete stems in_disassembly_inventory, uses bounded retries across bothllvm-mcandautomodes, and publishes viareplace_retry.#2553adds broader regression coverage (+265lines intests/test_shader_disasm.py,+38intests/test_shader_stage_resume.py,+24intests/test_rdna2spirv_cli.py).Thanks
@matinsaneifor the work and follow-up fixes on this issue.(AI-assisted review.)