Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dereferencing a rooted Gc during collection #163

Merged
merged 1 commit into from
Feb 5, 2023

Conversation

andersk
Copy link
Collaborator

@andersk andersk commented Feb 5, 2023

Ordinarily, objects dropped during collections would only contain unrooted Gc pointers. But with #[unsafe_ignore_trace] it’s possible to smuggle a rooted Gc pointer into the heap. When we collect a rooted Gc pointer, we need to dereference it in order to unroot its contents. This should be safe because the associated allocation cannot have been collected while the Gc is rooted.

Fixes an assertion failed: finalizer_safe() panic in the included test case (refs #52).

Ordinarily, objects dropped during collections would only contain
unrooted Gc pointers.  But with `#[unsafe_ignore_trace]` it’s possible
to smuggle a rooted Gc pointer into the heap.  When we collect a
rooted Gc pointer, we need to dereference it in order to unroot its
contents.  This should be safe because the associated allocation
cannot have been collected while the Gc is rooted.

Fixes an “assertion failed: finalizer_safe()” panic in the included
test case (refs Manishearth#52).

Signed-off-by: Anders Kaseorg <[email protected]>
@Manishearth Manishearth merged commit 2b9e451 into Manishearth:master Feb 5, 2023
@andersk andersk deleted the ignore-trace-panic branch February 6, 2023 22:47
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.

2 participants