diff options
| author | xel1uz <16402913+xel1uz@users.noreply.github.com> | 2026-11-25 07:56:53 +0100 |
|---|---|---|
| committer | xel1uz <16402913+xel1uz@users.noreply.github.com> | 2026-11-25 07:58:47 +0100 |
| commit | 362b854007f09b5f0c61ea9c4829cd9f7d3b26ce (patch) | |
| tree | 450b7978726e8aa32f2dbb22db1a99d5a59b0141 /runtime/src/thread_stacks.cpp | |
| parent | 42537e7b6f84c233ac009b924d3a25d2a1178197 (diff) | |
feature_scan: write --out atomically and keep the old report on failure
Write JSON to a same-directory temporary file and replace the report only after serialization succeeds. On write failure, keep the existing report and remove the temporary file; preserve the current error message and exit code.
Evidence (run from /home/hampa/work/leonida-feature-scan):
Tests:
- Original: git checkout upstream/main -- tools/feature_scan.py && /home/hampa/work/.venv/bin/python -m pytest tests/test_feature_scan.py -q -> rc 1; 1 failed, 15 passed. The existing report was empty instead of the 23-byte sentinel.
- Fixed: git checkout HEAD -- tools/feature_scan.py && /home/hampa/work/.venv/bin/python -m pytest tests/test_feature_scan.py -q -> rc 0; 16 passed.
File-size-limit reproduction (synthetic shaders only):
- Setup: mkdir -p /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders/dxbc /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out; python3 -c 'import json,sys; json.dump([{"stage":"synthetic_stage_"+str(i)+"_"+("x"*80)} for i in range(40)], open(sys.argv[1],"w"))' /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders/dxbc/index.json; printf '{"previous": "sentinel report"}\\n' > /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json
- Before: bash -c 'ulimit -f 1; python3 -I -B tools/feature_scan.py "$1" --out "$2" >/dev/null' _ /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json -> rc 2; report 32 bytes before, 1024 bytes after (old contents replaced by partial JSON).
- After: bash -c 'trap "" XFSZ; ulimit -f 1; python3 -I -B tools/feature_scan.py "$1" --out "$2" >/dev/null' _ /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json -> rc 2; report 32 bytes before and after, with no temp file remaining.
Diffstat (limited to 'runtime/src/thread_stacks.cpp')
0 files changed, 0 insertions, 0 deletions