tools/shader_carve_accel: release non-readonly/empty buffer pins and guard native fallback #1869
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1869
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/shader-carve-accel-safety"
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 successfully merged and closed
Claimed in the coordination issue as: SHADER-CARVE-ACCEL-SAFETY-AND-UNIT-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164153026)
What and why
path.is_file()before callingctypes.CDLLin_load_native()(tools/shader_carve_accel.py) so a missing optional native binary returnsNonecleanly.false,off, andno(case-insensitive, stripped) identically to0forLEONIDA_SHADER_CARVE_NATIVE.Py_bufferpin inentry_search()whennot view.readonly,view.len <= 0, ornot view.bufso writable (bytearray/ writablemmap) and empty buffers do not stay pinned on fallback, and guardfinallycleanup against double-release.isinstance(pos, int) and not isinstance(pos, bool) and 0 <= pos < view.lenbefore invoking nativescan, and also catchTypeError/OverflowErrorwhen falling back cleanly toreference(pos).tests/test_shader_carve_accel.py.Tested
python -I tests/test_shader_carve_accel.py -v->Ran 4 tests in 0.015s(OK);python -I tests/test_shader_carve.py -v->Ran 31 tests in 1.434s(OK);python -I tests/test_shader_carve_native.py -v->Ran 3 tests in 0.016s(OK (skipped=1),NativeParityTestskipped because the optional compiled native library is not present on this host).upstream/main5e95fa2fwithtests/test_shader_carve_accel.pycopied into detached worktree):Ran 4 tests in 0.012s(FAILED (failures=6, errors=2)).python -I tests/test_ci_registration.py(Ran 16 tests in 5.145s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 12.917s,OK),python -I scripts/check_no_game_data.py(exit 0),python -I -m compileall -q(exit 0),git diff --check(exit 0).GPUs tested: n/a (Py_buffer lifetime, fallback, and native-scanner safety unit tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Tested
7e38f9b24on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain71a769d7d(Python shader tool; no GPU):tests/test_shader_carve_accel.py: 4 passed, 14 subtests passed at this head.main: 8 failed, 1 passed — theis_file()/native-library load guard, thefalse/off/noenv handling and the native-fallback cases are new tests.AI-assisted; synthetic fixtures only, no game data.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_shader_carve_accel.py:tools/shader_carve_accel.py: 8 failed, 1 passed. So the tests catch the problem, and the tool change fixes it on Windows.(AI-assisted test run; output checked by hand.)
Red/green: On main test_shader_carve_accel.py has 6 failures and 2 errors (buffer pins not released, native loader called despite the disable variable), and with the PR all 4 tests pass on Windows 11 at OreoFR's (RTX 4070).
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
Verified by OreoFR
3408969a7+ PR head7e38f9b24python -I tests/test_shader_carve_accel.pyAI-assisted (Claude Code, Claude Opus 5.5).