Skip to content

Fix Box::unwrap leaking the heap allocation - #10

Merged
Cod-e-Codes merged 1 commit into
mainfrom
fix/box-unwrap-leak
Aug 12, 2026
Merged

Fix Box::unwrap leaking the heap allocation#10
Cod-e-Codes merged 1 commit into
mainfrom
fix/box-unwrap-leak

Conversation

@Cod-e-Codes

Copy link
Copy Markdown
Owner

Summary

  • Box::unwrap now copies T out, then calls ion_box_free on the box pointer. It does not drop T, so nested heap in the payload is not double-freed.
  • The unwrap argument is still move-marked, so scope-exit drop does not free the same allocation again (test_box_unwrap_same_scope.ion).
  • cgen must_match for ion_box_free(_box), plus a Linux CI leak-sanitizer step (detect_leaks=1) on unwrap tests. Existing ASan smoke stays at detect_leaks=0.

Test plan

  • cargo fmt, clippy -D warnings, cargo test
  • tests/test_runner.sh (272/272)
  • Example ion-build for all 14 examples; non-interactive examples run

Copy T out then ion_box_free the box pointer without dropping T, so nested heap in the payload is not double-freed. Move-marking still skips a second free at scope exit.
@Cod-e-Codes
Cod-e-Codes merged commit b6a41ad into main Aug 12, 2026
7 checks passed
@Cod-e-Codes
Cod-e-Codes deleted the fix/box-unwrap-leak branch August 12, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant