Skip to content

fn mem::transmute: Replace with sound Arc::from_raw(Arc::into_raw(…) as *const _)#1361

Merged
kkysen merged 2 commits intomainfrom
kkysen/Arc-from_raw-into_raw-instead-of-transmute
Sep 25, 2024
Merged

fn mem::transmute: Replace with sound Arc::from_raw(Arc::into_raw(…) as *const _)#1361
kkysen merged 2 commits intomainfrom
kkysen/Arc-from_raw-into_raw-instead-of-transmute

Conversation

@kkysen
Copy link
Collaborator

@kkysen kkysen commented Sep 24, 2024

As @Darksonn pointed out, using mem::transmute on an Arc is unsound since it's not #[repr(transparent)], and we need to go through Arc::into_raw and Arc::from_raw with a ptr cast instead.

…...) as *const _)` as `Arc` is not `#[repr(transparent)]`.
@kkysen kkysen merged commit acd57b1 into main Sep 25, 2024
@kkysen kkysen deleted the kkysen/Arc-from_raw-into_raw-instead-of-transmute branch September 25, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants