-
Notifications
You must be signed in to change notification settings - Fork 268
Use MaybeUninit in memory manager and Pod-related code #2555
Description
The memory manager allows you to copy data to/from the managed process, and uses the Pod trait to restrict what types can be copied through the memory manager. While any initialized byte representation is valid for a "pod" type, that doesn't mean we can cast a pod type to a &[u8] since the type may have padding bytes that will invoke UB when read. For example MemoryCopier::copy_to_ptr() takes a &[T: Pod] as an argument and converts it to a &[u8], which if read may invoke UB if T has padding bytes. There are other cases such as socket addresses where we have a pointer and length to copy to the plugin, but shouldn't cast them to a &[u8] since there may be padding bytes in the socket address. So it would be nice if the memory manager accepted a &[MaybeUninit<u8>] or more generally a &[MaybeUninit<T: Pod>] to copy to the managed process.