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

Gc::from_raw: Set the Gc as a root #122

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

andersk
Copy link
Collaborator

@andersk andersk commented Jan 24, 2021

The recovered Gc is not inside a GcBox on the heap, so it must be set as a root (like it must have been when it was originally passed to Gc::into_raw). Otherwise, putting it into another Gc will panic with “Can't double-unroot a Gc<T>”.

@andersk andersk mentioned this pull request Jan 24, 2021
The recovered Gc is not inside a GcBox on the heap, so it must be set
as a root (like it must have been when it was originally passed to
Gc::into_raw).  Otherwise, putting it into another Gc will panic with
“Can't double-unroot a Gc<T>”.

Signed-off-by: Anders Kaseorg <[email protected]>
@Manishearth
Copy link
Owner

I'm a bit confused, currently into_raw() does not unset the root flag; why would from_raw need to re-set it?

@andersk
Copy link
Collaborator Author

andersk commented Jan 25, 2021

into_raw() does unset the root flag, via deref()inner()clear_root_bit().

@Manishearth
Copy link
Owner

Ah! I understand

@Manishearth Manishearth merged commit 910624b into Manishearth:master Jan 25, 2021
@andersk andersk deleted the from_raw-root branch April 3, 2021 21:50
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