Repository navigation
fix(rules): allow BMesh ownership transfer; make the handoff sites leak-proof - #438
Merged
Merged
Conversation
…ak-proof always-free-bmesh called `return bm` and builder hand-offs wrong, yet the codebase relies on both: traffic-cones' cone_bm()/board_bm() return a BMesh the caller frees, and custom-normals-shade builds a BMesh and hands it to finish_mesh(), which frees it in finally. The rule now allows transfer when every path has exactly one owner that frees, and names what stays wrong (an owner-less path). The sites themselves had owner-less paths: the four traffic-cones callers freed outside finally, and the three custom-normals builders could raise between bmesh.new() and the hand-off. Callers now free in finally; builders free on failure (except BaseException: free; raise) and hand off on success. Closes #401 Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
CI evidence before merge: all checks pass ( 13 pass ). Blender Smoke on PR head: Blender 5.2.2 LTS / Blender 4.5.14 LTS. Summaries (happy path; falsifiers) per leg: 143 passed, 1 skipped, 0 failed;143 passed, 0 skipped, 0 failed;141 passed, 3 skipped, 0 failed;136 passed, 7 skipped, 0 failed; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #401.
What changed
rules/always-free-bmesh.mdcadds a section, "Ownership transfer is allowed, if exactly one owner frees". A builder may return a BMesh, or hand it to a finisher that frees it. Until then, it must free the BMesh on every failure path.claude/blender-rules.mdis regenerated.examples/custom-normals-shade/custom_normals_shade.py: the three builders that hand their BMesh tofinish_mesh()now wrap the build intry: … except BaseException: bm.free(); raise. Success still hands off.showcase/traffic-cones/traffic_cones.py: the 4 callers ofcone_bm()/board_bm()free the returned BMesh infinally.Evidence
Live run on local Blender 5.2.1: old (main) and new copies of each script ran under a wrapper. The wrapper hashes every mesh's vertex coordinates, faces and corner normals after the script exits.
a5089c84039204e0a5089c84039204e0af13cd9d4a3f5e68af13cd9d4a3f5e68The stdout of each pair differs only in glTF exporter timestamps.
Local checks:
check_example_rules.pypasses, andbuild_claude_rules.pyproduces no diff.Inspection only: the failure paths (an exception between
bmesh.new()and the handoff) were not triggered live.🤖 Generated with Claude Code