Repository navigation
glb_writer, rtti_scan: find a new file's mode without touching the umask - #866
Conversation
|
Tested on Linux (WSL2 Ubuntu), Python 3.12, CPU only: pass
|
|
Reviewed 808c947: 1 finding, plus an offer The lock fixes writer-vs-writer, but as @kapitche says, any other thread creating a file during the set-and-restore still gets umask 0. I'd also started on this from their #728/#750 comments before seeing your claim, so I haven't opened a PR. Instead, here is a branch you can take or ignore: kotorvr:fix/umask-probe (a85be7b).
Windows 11, Python 3.13.7: If you'd rather keep the lock, that's fine too. Then reading once at import, as kapitche suggested, would close the window for other threads. Say if you want me to open the branch as its own PR after yours instead. AI-assisted (Claude Code). |
808c947 to
a85be7b
Compare
|
Thanks both. You're right that the lock only ordered GLB writers. I've replaced my commit with @kotorvr's a85be7b (their authorship kept), so neither tool touches the umask any more; description updated. Rebased on 4a36bb1; |
…the umask glb_writer._output_mode and rtti_scan._report_mode read the umask with os.umask(0) then os.umask(mask). The umask is process-wide, so any thread creating a file in that window got mask 0. A probe file created with mode 0666 gives the same bits (and honours a directory's default ACL) without changing anything. Raised by kapitche on ItsNotRexed#750 and ItsNotRexed#728. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a85be7b to
430265a
Compare
|
The first version (808c947, the umask lock) landed on |
|
Review: not ready — the rebase onto current main leaves one of main's own tests broken. Blocking:
Everything else on this head is green here: The approach itself is right: neither tool calls AI-assisted (omp orchestrator). |
|
Thanks @quackottu for taking it, and @abilliontokens for catching the stale test. My fault: I wrote the helper against a main that didn't have the lock test yet. The fix is one commit on top of your head, 430265a: kotorvr:fix/umask-probe-2 (65a9e14). Fetch it with Ran on Windows 11, Python 3.13.7, on 65a9e14:
AI-assisted (Claude Code). |
test_glb_atomic still drove glb_writer._output_mode through a fake umask; #866 moved the mode to file_mode.published_mode, which uses a probe file and never sets the umask, so the test now checks exactly that. test_run_gpu_wavemask's fake run_cmd takes the gpu= keyword. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New BUILD item, claimed in #634 (#634 (comment)), from my review of #728.
tools/glb_writer.pyandtools/rtti_scan.pyread the umask withos.umask(0)thenos.umask(mask). The umask is process-wide, so while one thread is inside that pair every other thread that creates a file gets umask 0, and two GLB writers can interleave so the process stays at 0 for good.My first version put a lock around the pair; @kapitche and @kotorvr pointed out in review that it only orders GLB writers, not other threads. This now uses @kotorvr's commit (a85be7b, authored by them, taken with their offer in the review) instead, which never touches the umask:
tools/file_mode.py:new_file_mode(dir)creates a.mode-<random>.probewithos.open(..., O_CREAT|O_EXCL, 0o666), reads the bits back withfstatand removes it, so the current umask and a directory's default ACL apply without changing process state.published_mode(path)returns the replaced file's bits, or that.glb_writerandrtti_scanboth use it.tests/test_file_mode.py: patchesos.umaskto raise and runswrite_glbandwrite_reporton a new and a replaced file (fails withmain's tools); POSIX cases for 0640 under umask 027 and 0664 under 002, and no probe left behind.Tested on Windows 11 Pro (26300), Python 3.12.10:
test_file_modeOK (2 POSIX skips),test_glb_atomicOK (1 skip),test_rtti_scanOK (1 skip),test_glb_writerOK. @kapitche's WSL run covered the POSIX side of the earlier version; the POSIX cases oftest_file_modehaven't run yet.AI-assisted.