#1 Unrestrict the memory alignment of the Representable of an [u8]

Opened by Kerollmops on February 14, 2021
Kerollmops on February 14, 2021

Hello,

I would like to remove the alignment of 2 of the [u8] (slice of bytes) to become 1. It is possible to do so by copying the bytes that represent the length by using u16::from_le_bytes.

To use this function we must first transform the pointer of bytes into a slice but we only know that it must be two u8s, so we use the slice::from_raw_parts function to do so. Once we have our slice we need to make it an array of two bytes and give it to u16::from_le_bytes.

The thing is I don’t understand why the conversion between a slice of two bytes into an array of two bytes doesn’t succeed. It really seems to be a bug, maybe even a bug where there is some stack corruption. F*ck it!

This works in the playground but not in the code part I publish in this discussion.

Kerollmops added a change on February 14, 2021
GTBDZYZZP6TRTCC5OYDGKZN6AKJEKCK6Y6BJYPRG5Q7SQJ7M7ZEQC
fogti on February 16, 2021

In the attached change, there is an unrelated change section which adds a dependency on uuid, which probably shouldn’t be part of the change.