Skip to content

shader_disasm: listings get the umask's mode bits, not the staging file's 0600 - #7573

Open
best2135 wants to merge 1 commit into
ItsNotRexed:mainfrom
best2135:hunt/shader_disasm-listing-mode
Open

best2135 wants to merge 1 commit into
ItsNotRexed:mainfrom
best2135:hunt/shader_disasm-listing-mode

Conversation

@best2135

Copy link
Copy Markdown

Claimed on #7333 (shader_disasm).

What was wrong. Each .s listing is written to a tempfile.NamedTemporaryFile (created 0600) and os.replaced into the output folder, with no mode fix-up. The other staged writers give the staged file the destination's bits through file_mode.published_mode (#1082). Listings therefore came out 0600 where a plain open() gives 0644 under umask 022, and a re-run lost the mode of the listing it replaced.

Hand-built input. The existing hand-built FSSM blob and fake llvm-mc of tests/test_shader_disasm.py produce one.s; its mode was 0o600 against 0o644 for a plain open() in the same folder. New test test_a_listing_gets_the_bits_of_a_plain_open failed before the change (384 != 420) and passes now.

Tests (Linux, Python 3.14, CPU only, no GPU):

  • python3 -I tests/test_shader_disasm.py: 30 tests OK (the new one failed before the fix)
  • python3 -m compileall -q make_game.py tools tests
  • python3 -I scripts/check_no_game_data.py tools/shader_disasm.py tests/test_shader_disasm.py: clean

AI-assisted.

🤖 Generated with Claude Code

…ot the staging file's 0600

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: passes all 30 tests in tests/test_shader_disasm.py. Applying published_mode(target) via os.chmod before os.replace ensures atomic staging doesn't leave output listings restricted to 0600.

@theo-bggtt

Copy link
Copy Markdown

Tested 0c29265 merged onto main 25e425a on Windows 11, CPython 3.14.4, CPU only, no game files: pass, the Windows side of a POSIX-mode change.

  • Merge: clean. python -I tests/test_shader_disasm.py: main 29 OK, head 30 OK with the new test skipped (POSIX permission bits), as intended on nt.
  • What Windows checks here: the new os.chmod(listing.name, published_mode(target)) runs on Windows in the 9 existing tests that publish a listing through one() (11 listings in all; one replaces an existing file, the other 10 take the new_file_mode branch because the target does not exist yet), and none regresses. So a first run has no FileNotFoundError from published_mode either. Twenty-three other tools already do the same chmod-before-replace on a staged file (awc_manifest, bvh_index, progress_dashboard, ...), so this matches the repository's pattern.
  • compileall, git diff --check and scripts/check_no_game_data.py on both files: clean.

The mode assertion itself still needs a Linux or macOS run; the author's Linux run covers it.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants