Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Illegal use of mem::zeroed() #18

Open
RalfJung opened this issue Dec 23, 2019 · 2 comments · Fixed by JakubOnderka/treebitmap#9
Open

Illegal use of mem::zeroed() #18

RalfJung opened this issue Dec 23, 2019 · 2 comments · Fixed by JakubOnderka/treebitmap#9

Comments

@RalfJung
Copy link

The use of mem::zeroed at

looks illegal: mem::zeroed may only be used for types that actually allow zero-initialization, and here this is done for any user-controlled type T. So, e.g. if T is a reference, this is UB as references must not be all-zero.

If you just want to write a bunch of zero bytes to memory, I suggest using write_bytes.

@RalfJung
Copy link
Author

Heads-up: with rust-lang/rust#66059, this will turn into a panic to protect people from UB. The crater log indicates that the type you are zero-initializing here is &str -- references must indeed never be null.

Cc @JakubOnderka, maintainer of ip_network_table, which according to crater will also be affected when the UB here turns into a panic.

@nico-abram
Copy link

This issue is resolved right? It's still open

cc @JakubOnderka , @hroi

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants