mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:40:52 +01:00
[PR #612] [MERGED] hw_oracle: remove the temp workdir when the constructor fails (HW-ORACLE-WORKDIR-LEAK) #654
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#654
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/612
Author: @TuroYT
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:fix/hw-oracle-workdir-leak📝 Commits (1)
b68ce6chw_oracle: remove the temp workdir when the constructor fails (HW-ORACLE-WORKDIR-LEAK)📊 Changes
3 files changed (+187 additions, -13 deletions)
View changed files
➕
tests/test_hw_oracle_workdir_leak.py(+162 -0)📝
tools/hw_oracle/drm.py(+15 -9)📝
tools/hw_oracle/runner.py(+10 -4)📄 Description
Claimed in the coordination issue as: HW-ORACLE-WORKDIR-LEAK (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128008469)
What was wrong.
DrmOracle.__init__(tools/hw_oracle/drm.py, line 158) andOracle.__init__(tools/hw_oracle/runner.py, line 212) calltempfile.mkdtemp(...)and then can raiseUnavailable: the launcher build, the arch lookup, the probe.close()removes the workdir, but it is never reached for an object whose constructor raised. Every skipped run (exit 77) therefore left aleonida-hw-oracle-*directory in the temp dir.Reproduced on
main(21625bca8) with the build step stubbed to raise: 3 skippedDrmOracleconstructions left 3 directories, and 3 skippedOracleconstructions left 3 more.What changed. In both constructors, the steps after
mkdtemprun inside atry. On anyBaseExceptionthe workdir is removed, but only if the constructor created it (owned = not workdir, the same test asworkdir or mkdtemp(...)), and the exception is re-raised. A caller-suppliedworkdiris never removed. The new test is intests/test_hw_oracle_workdir_leak.py; no existing file is touched beyond the two constructors.Overlap with #297. #297 changes only
tests/test_hw_oracle_drm.py, so the two PRs share no file. Its tests pass a caller-suppliedworkdir=, which this change leaves alone. I did not run a merge of the two branches.Tested:
python3 -I tests/test_hw_oracle_workdir_leak.pyon the unfixed constructors:FAILED (failures=5)(the 3DrmOracleand 2Oracleleak cases); the caller-workdir and success cases pass.Ran 9 tests ... OK.TMPDIRset to an empty directory: before the fix 3 leftover directories (DrmOracle) and 6 in total; after the fix 0.workdir=""(treated as not given) leaves nothing; aKeyboardInterruptraised in the probe is re-raised and leaves nothing; an arch lookup failure after the build leaves nothing; a successful construction keeps its directory untilclose().python3 -I tests/test_hw_oracle.py:OK (skipped=3);python3 -I tests/test_hw_oracle_asm_strip.py:OK;python3 -m compileall -q tools tests: ok;python3 -I tests/test_text_write_line_endings.py:OK;python3 -I scripts/check_no_game_data.pyon the three changed files: exit 0.Not tested: a real GPU or DRM run (the probe was replaced by a stub in every case), and the Windows path, which uses
hw_oracle.cand was not exercised.AI-assisted (Claude Code).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.