spirv_asm: refuse an output that aliases the source (OLD-10025) #750

Closed
github-bot wants to merge 1 commit from gh-pr/750/head into gh-pr/750/base
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:29 UTC · original
abnalstlll-byte:restore/old-10025-spirv-asm-alias → main · +33 −0 · 2 files · 1 commits · closed without merging

### Summary
Restores and updates work from draft PR #293 (old-pr/10025 / item OLD-10025).
Original commit by @⁠igorborgest (8e33f7866).

tools/spirv_asm.py previously permitted an output -o argument that aliased the source .spvasm file, clobbering the source file on write.
This change uses same_report_path to detect path aliasing (direct same path, .. canonicalizations, symlinks, and hardlinks) and refuses the command with an error (ap.error("output must not overwrite the source")).

Verification

  • python -I scripts/check_no_game_data.py tools/spirv_asm.py tests/test_spirv_asm.py -> Clean (no game data)
  • python -m unittest tests/test_spirv_asm.py -> 36/36 PASS, 1 skip in 3.26s
  • Clean rebase onto latest ubi/main (2d73c242f).

AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/750) `abnalstlll-byte:restore/old-10025-spirv-asm-alias` → `main` · +33 −0 · 2 files · 1 commits · closed without merging ### Summary Restores and updates work from draft PR #293 (`old-pr/10025` / item `OLD-10025`). Original commit by @⁠igorborgest (`8e33f7866`). `tools/spirv_asm.py` previously permitted an output `-o` argument that aliased the source `.spvasm` file, clobbering the source file on write. This change uses `same_report_path` to detect path aliasing (direct same path, `..` canonicalizations, symlinks, and hardlinks) and refuses the command with an error (`ap.error("output must not overwrite the source")`). ### Verification - `python -I scripts/check_no_game_data.py tools/spirv_asm.py tests/test_spirv_asm.py` -> Clean (no game data) - `python -m unittest tests/test_spirv_asm.py` -> 36/36 PASS, 1 skip in 3.26s - Clean rebase onto latest `ubi/main` (`2d73c242f`). AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:19:26 +00:00
github-bot closed this pull request 2026-11-26 09:19:26 +00:00
Author
Owner

@⁠Poussistar on GitHub · 2026-11-24 17:32 UTC · original

Rebase needed: one hunk of tools/spirv_asm.py no longer applies to main 32950551e.

git apply stops at tools/spirv_asm.py:29: main now imports from fractions import Fraction in that block, so from spirv_asm_tables import ( sits at line 32 and wraps onto two lines. Your main() hunk (the same_report_path guard after args = ap.parse_args(argv)) still matches, and tests/test_spirv_asm.py applies unchanged.

To separate a stale hunk from a wrong fix, I re-applied the import and the two guard lines by hand on 32950551e (Linux, CPython 3.14.7) and ran your test file:

$ python -I tests/test_spirv_asm.py
Ran 38 tests in 0.475s
OK (skipped=1)

Negative control, the two guard lines removed and nothing else changed:

$ python -I tests/test_spirv_asm.py
FAILED (failures=4, skipped=1)
AssertionError: 0 != 2

So the test does catch the alias (same path, sub/.., hard link and symlink all four fail without the guard), and main has no protection today: grep -n 'same_report_path\|overwrite' tools/spirv_asm.py finds nothing, and -o pointing at the source still overwrites it.

Rebase onto current main and it is ready for review from my side. No game files involved. AI-assisted.

**@⁠Poussistar** on GitHub · 2026-11-24 17:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/750#issuecomment-7139358576) Rebase needed: one hunk of `tools/spirv_asm.py` no longer applies to `main` `32950551e`. `git apply` stops at `tools/spirv_asm.py:29`: `main` now imports `from fractions import Fraction` in that block, so `from spirv_asm_tables import (` sits at line 32 and wraps onto two lines. Your `main()` hunk (the `same_report_path` guard after `args = ap.parse_args(argv)`) still matches, and `tests/test_spirv_asm.py` applies unchanged. To separate a stale hunk from a wrong fix, I re-applied the import and the two guard lines by hand on `32950551e` (Linux, CPython 3.14.7) and ran your test file: $ python -I tests/test_spirv_asm.py Ran 38 tests in 0.475s OK (skipped=1) Negative control, the two guard lines removed and nothing else changed: $ python -I tests/test_spirv_asm.py FAILED (failures=4, skipped=1) AssertionError: 0 != 2 So the test does catch the alias (same path, `sub/..`, hard link and symlink all four fail without the guard), and `main` has no protection today: `grep -n 'same_report_path\|overwrite' tools/spirv_asm.py` finds nothing, and `-o` pointing at the source still overwrites it. Rebase onto current `main` and it is ready for review from my side. No game files involved. AI-assisted.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:41 UTC · original

Rebased onto current main (71f99e224); ools/spirv_asm.py imports apply cleanly now and python -I tests/test_spirv_asm.py passes (38 tests run, 1 skipped). Thank you for the check @⁠Poussistar!

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 18:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/750#issuecomment-7141005382) Rebased onto current main (71f99e224); ools/spirv_asm.py imports apply cleanly now and python -I tests/test_spirv_asm.py passes (38 tests run, 1 skipped). Thank you for the check @⁠Poussistar!
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-25 17:13 UTC · original

Thanks! The same commit (spirv_asm output/source alias refusal) is already in main through #938 (merge 466f115ac), and this diff reverse-applies cleanly on current main, so this PR may no longer be needed.

AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).

**@⁠MoonEyes** on GitHub · 2026-11-25 17:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/750#issuecomment-7169197688) Thanks! The same commit (spirv_asm output/source alias refusal) is already in main through #938 (merge 466f115ac), and this diff reverse-applies cleanly on current main, so this PR may no longer be needed. AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 17:54 UTC · original

Thanks, @⁠abnalstlll-byte. This change is already in main through #938 (merge 466f115ac): merged onto current main, this branch adds no lines. Closing as done, not rejected. Your rebase work was right, the same fix just landed first under its other item ID. Thanks also @⁠MoonEyes for spotting it.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 17:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/750#issuecomment-7170169417) Thanks, @⁠abnalstlll-byte. This change is already in `main` through #938 (merge `466f115ac`): merged onto current `main`, this branch adds no lines. Closing as done, not rejected. Your rebase work was right, the same fix just landed first under its other item ID. Thanks also @⁠MoonEyes for spotting it. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.