[Rust] Correct object ownership and callback threading contracts - #770
Closed
tlopex wants to merge 7 commits into
Closed
[Rust] Correct object ownership and callback threading contracts#770tlopex wants to merge 7 commits into
tlopex wants to merge 7 commits into
Conversation
Seven-Streams
approved these changes
Sep 8, 2026
Destroy initialized elements when the last strong reference is released, while preserving weak-reference allocation cleanup. Track initialized length during construction and cover native mutation and foreign-thread callback cleanup.
tqchen
approved these changes
Sep 9, 2026
…e#770) Separate the neutral ABI header from the full-object thread-safety contract. Keep shareable Functions restricted to Send + Sync captures, remove TLS callback APIs, and require handles for reflected field reads. Remove generic ObjectArc DerefMut so safe replacement cannot overwrite a live intrusive header. Update container initialization and generated accessors while retaining the independent array and weak-owner lifetime fixes.
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.
This PR updates Rust object and callback safety using the existing APIs, without introducing thread-local functions or new C ABI interfaces.
Send + Syncbounds fromFunction::from_packedandFunction::from_typed. These constructors becomeunsafe: callers must preserve the captures’ threading requirements, including calls and final release through native copies.Send/Syncimplementations forFunction. Make global registrationunsafe, since registered functions become accessible across threads.ObjectArc::DerefMut, which could overwrite a live reference-count header even under unique ownership. Keep the common object header free of thread-confinement markers, without inferring that arbitrary object handles are thread-safe.These are Rust source-compatibility changes. The C ABI and object layouts remain unchanged.