Implement Send on BootInformation?
roblabla opened this issue · 5 comments
BootInformation doesn't implement Send, because it contains a raw pointer. From the nomicon:
A type is Send if it is safe to send it to another thread.
The pointer inside the BootInformation is const, so we cannot modify it across threads anyways. Is there any downside to doing an unsafe impl Send for BootInformation {} ? My goal is to store it inside a spin::Once<T>, and that requires it to be Send.
Hi @roblabla, thanks for opening this issue and sorry for the delay.
I don't see any problem with implementing Send, because we don't provide methods to modify the boot information and the pointers should have 'static lifetime.
@rust-osdev/multiboot2 What do you think?
ping @rust-osdev/multiboot2
As far as I can see, it’s safe to implement Send as long as we don’t ever unsafely cast that pointer to be mutable (afaik we never do).
I’m not sure it’s the best design, however. Accessing the packed fields can be slow (as stuff can be unaligned) and so I wonder if it’s generally better to extract the information into your own data structures during initialisation
I agree with you @IsaacWoods
Alright. Extracting into your own structs seems to be the desired solution. Please reopen if you have other views.