Skip to content

fix(examples): free hay-bale's bmesh on every path; per-run depsgraph-export OBJ - #421

Merged
TMHSDigital merged 1 commit into
mainfrom
fix/tempfile-and-bmesh-leak
Oct 5, 2026
Merged

TMHSDigital merged 1 commit into
mainfrom
fix/tempfile-and-bmesh-leak

Conversation

@TMHSDigital

Copy link
Copy Markdown
Owner

Closes #404. Refs #401: this fixes the hay-bale defect. The rule-vs-builder-class mismatch #401 also describes is left for the rule lint in #400.

hay-bale (#401)

  • belt_depths() helper: bm = bmesh.new(), then try: … if not bm.faces: return [] … finally: pass. The early return leaked the BMesh, and the later bm.free() was outside any finally. It now frees in finally.
    • This is safe because BVHTree.FromBMesh copies the geometry, and the evidence below confirms it.
  • --stray-vert falsifier path: from_mesh / to_mesh / free had no try; it is now wrapped.

depsgraph-export (#404)

  • It wrote gettempdir()/depsgraph_export.obj (plus .mtl) and never removed it. A previous run's OBJ could therefore satisfy the exists and size > 0 check when an export wrote nothing.
  • It now uses a pid-suffixed name and deletes .obj and .mtl before the export and in finally. A caller-supplied obj_path is still pre-deleted but kept afterwards.

Evidence

Live run (--factory-startup --python-exit-code 1; binary reports 5.2.1 LTS). Each script was run on unmodified main first, then on this branch:

Run Before After
hay_bale.py exit 0 exit 0, stdout identical (every measured figure)
hay_bale.py --stray-vert (catalog falsifier) exit 15 exit 15, stdout identical
depsgraph_export.py exit 0; left %TEMP%\depsgraph_export.obj + .mtl behind exit 0; stdout differs only in the temp file name and export ms; no file left behind
depsgraph_export.py --unevaluated (falsifier) n/a exit 5, unchanged contract

check_exit_code_readme and check_helper_drift pass.

🤖 Generated with Claude Code

…-export OBJ

hay-bale (#401): a measurement helper built a bmesh inside
`try: ... finally: pass`, so its early `return []` leaked the BMesh and
the later bm.free() was unprotected; the --stray-vert falsifier path did
from_mesh/to_mesh/free with no try at all, the literal "WRONG" example
of the always-free-bmesh rule. Both now free in finally. BVHTree.FromBMesh
copies the geometry, so freeing before the ray casts is safe: the
piece's full output is byte-identical before and after.

depsgraph-export (#404): the export wrote gettempdir()/depsgraph_export.obj
and never removed it, so a previous run's OBJ could satisfy the "file
exists" check when an export wrote nothing (and Blender points TMPDIR at
the working directory). It now uses a pid-suffixed name and deletes the
.obj and .mtl before and after.

Closes #404
Refs #401

Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added examples Runnable smoke-gated examples under examples/ showcase Budget-conformance props under showcase/ labels Oct 5, 2026
@TMHSDigital

Copy link
Copy Markdown
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;142 passed, 0 skipped, 0 failed;141 passed, 3 skipped, 0 failed;136 passed, 6 skipped, 0 failed;

@TMHSDigital
TMHSDigital merged commit db2ca4b into main Oct 5, 2026
13 checks passed
@TMHSDigital
TMHSDigital deleted the fix/tempfile-and-bmesh-leak branch October 5, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Runnable smoke-gated examples under examples/ showcase Budget-conformance props under showcase/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

examples: depsgraph-export writes a fixed temp filename and never cleans up, so a stale OBJ can satisfy its check

1 participant