Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashbrown is not following strict provenance #384

Closed
RalfJung opened this issue Jan 9, 2023 · 4 comments · Fixed by #390
Closed

hashbrown is not following strict provenance #384

RalfJung opened this issue Jan 9, 2023 · 4 comments · Fixed by #390

Comments

@RalfJung
Copy link
Member

RalfJung commented Jan 9, 2023

hashbrown is using int-to-ptr casts in some places, instead of the strict provenance APIs:

(index + 1) as *mut T

mem::align_of::<T>() as *mut T

(self.ptr.as_ptr() as usize + offset) as *mut T

(there might be more)

The cases I have found so far are all inside if Self::IS_ZERO_SIZED_TYPE {, so I assume these are "fake" pointers that are never dereferenced, and could be using ptr::invalid_mut.

The fuzzy_provenance_casts lint can be used to statically check for such casts. Currently however the strict provenance functions are still unstable.

@zakarumych
Copy link
Contributor

Should hashbrown use sptr crate for the time Strict Provenance API is unstable?

@bors bors closed this as completed in ae3e67b Mar 24, 2023
@RalfJung
Copy link
Member Author

@Amanieu is there a usual cadence for syncing hashbrown changes to the standard library?

Looks like the version shipped with current nightly still has the old int2ptr casts in it.

@Amanieu
Copy link
Member

Amanieu commented May 14, 2023

We currently have several breaking changes on master, and I'm finishing up some new feature which will be released in hashbrown 0.14. I think the release should happen in the next week or two.

@RalfJung
Copy link
Member Author

RalfJung commented May 14, 2023 via email

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

Successfully merging a pull request may close this issue.

3 participants