tooling: report damaged inputs in dxil_retarget without a traceback #658

Merged
louisdibiasi merged 1 commit from upstream-pr/664 into main 2026-11-22 18:46:41 +00:00
louisdibiasi commented 2026-11-22 18:29:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-22T18:29:44Z.


Change

tools/dxil_retarget.py raises ValueError for an input that is not a DXBC container or LLVM bitcode, for a truncated container and for a truncated bitcode stream, and OSError for an unreadable input. None was caught, so each ended in a traceback. The existing invalid-arguments check only requires a non-zero exit status, which a traceback also satisfies. This reports OSError and ValueError as dxil_retarget.py: <message> with exit status 1.

Independent problem, no linked issue.

Verification

Commit under test: 88ebeb3 on 719552e, Windows 11, Python 3.12.10.

python -B tools/dxil_retarget.py <input> out.bin, base vs this branch:

Input Base This branch
22 bytes of text ValueError: Input must be a DXBC container or raw LLVM bitcode traceback, exit 1 dxil_retarget.py: Input must be a DXBC container or raw LLVM bitcode, exit 1
DXBC0123456789abcdef ValueError: Expected a DXBC container traceback dxil_retarget.py: Expected a DXBC container
BC\xc0\xde\x00\x00 ValueError: Unexpected end of LLVM bitcode stream during alignment traceback one-line message
missing file FileNotFoundError traceback dxil_retarget.py: [Errno 2] No such file or directory: '<path>'

New cases in tests/dxil_retarget_check.py (check_pure_python_controls) run the CLI on the first three inputs and a missing path and require exit 1, no Traceback, and no output file.

  • Base: AssertionError at the first case (stderr shows the traceback).
  • This branch: pure-python dxil_retarget controls: ok.

Evidence and follow-up

Synthetic bytes only. The handler sits in the __main__ guard so it also covers the --pe path; valid inputs and the other error paths (for example CalledProcessError from a probe) are unchanged. The ValueError messages do not name the input file; only the missing-file message does.

Checklist

  • One reviewable behavior.
  • Exact commands and results above.
  • Negative control: the new cases fail on base.
  • No README/docs change needed.
  • No game files, dumps, links or secrets.

AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6546092007 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/664). Originally posted by [louisdibiasi](https://github.com/louisdibiasi) on 2026-11-22T18:29:44Z. --- ## Change `tools/dxil_retarget.py` raises `ValueError` for an input that is not a DXBC container or LLVM bitcode, for a truncated container and for a truncated bitcode stream, and `OSError` for an unreadable input. None was caught, so each ended in a traceback. The existing invalid-arguments check only requires a non-zero exit status, which a traceback also satisfies. This reports `OSError` and `ValueError` as `dxil_retarget.py: <message>` with exit status 1. Independent problem, no linked issue. ## Verification Commit under test: 88ebeb3 on 719552e, Windows 11, Python 3.12.10. `python -B tools/dxil_retarget.py <input> out.bin`, base vs this branch: | Input | Base | This branch | |---|---|---| | 22 bytes of text | `ValueError: Input must be a DXBC container or raw LLVM bitcode` traceback, exit 1 | `dxil_retarget.py: Input must be a DXBC container or raw LLVM bitcode`, exit 1 | | `DXBC0123456789abcdef` | `ValueError: Expected a DXBC container` traceback | `dxil_retarget.py: Expected a DXBC container` | | `BC\xc0\xde\x00\x00` | `ValueError: Unexpected end of LLVM bitcode stream during alignment` traceback | one-line message | | missing file | `FileNotFoundError` traceback | `dxil_retarget.py: [Errno 2] No such file or directory: '<path>'` | New cases in `tests/dxil_retarget_check.py` (`check_pure_python_controls`) run the CLI on the first three inputs and a missing path and require exit 1, no `Traceback`, and no output file. - Base: `AssertionError` at the first case (stderr shows the traceback). - This branch: `pure-python dxil_retarget controls: ok`. ## Evidence and follow-up Synthetic bytes only. The handler sits in the `__main__` guard so it also covers the `--pe` path; valid inputs and the other error paths (for example `CalledProcessError` from a probe) are unchanged. The `ValueError` messages do not name the input file; only the missing-file message does. ## Checklist - [x] One reviewable behavior. - [x] Exact commands and results above. - [x] Negative control: the new cases fail on base. - [x] No README/docs change needed. - [x] No game files, dumps, links or secrets. AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.
upstream-sync closed this pull request 2026-11-24 06:44:13 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!658
No description provided.