Skip to content

Guard disposed Rust object and trait wrappers - #172

Draft
chavic wants to merge 1 commit into
Uniffi-Dart:mainfrom
chavic:fix/disposal-guards
Draft

chavic wants to merge 1 commit into
Uniffi-Dart:mainfrom
chavic:fix/disposal-guards

Conversation

@chavic

@chavic chavic commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Following up on #70. Calling dispose() twice currently frees the same Rust handle again, and calling a method afterwards can clone that freed handle.

This adds a disposed state to regular objects, Rust-only trait wrappers, and Rust-backed foreign traits. A second dispose() becomes a no-op, while later calls or lowering through that wrapper throw StateError before reaching Rust. Another wrapper holding its own reference remains usable.

I've added tests for repeated disposal, use after disposal, native drop counts, and independently owned trait handles. Both fixture suites passed: 23 Dart tests, including the three new cases. Formatting and diff checks passed too.

This addresses the disposal guards in #70. The wider buffer cleanup and argument rollback work still needs its own fixes.

@chavic
chavic force-pushed the fix/disposal-guards branch from 4d48b3e to d1fc88b Compare September 11, 2026 16:02
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