-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.
Description
We currently have a lot of unsafe
reads of unions fields which is source of easy unsoundness. Let's make things easier while avoiding this completely:
- Change
s_no_extra_traits
to do an opaqueDebug
implementation on unions, hereLines 122 to 129 in 2f931d9
(it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] #[derive(Copy, Clone)] $(#[$attr])* pub union $i { $($field)* } } ); - Delete all existing
Debug
implementations on unions (which will now conflict).
The implementation is easy, this will just print the types as some_union { .. }
:
#[cfg(feature = "extra_traits")]
impl ::core::fmt::Debug for $i {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct(stringify!($i)).finish_non_exhaustive()
}
}
We can backport this to libc-0.2
since it fixes some soundness issues without breaking any API.
Metadata
Metadata
Assignees
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.