-
Notifications
You must be signed in to change notification settings - Fork 77
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
ABI break: z_stream::zalloc and z_stream::zfree should be able to set to None (null) #55
Comments
rust-lang/rust#66059 is gonna turn some code into panic, i think. |
Oh so these are function pointers ( |
@RalfJung Yes, and that will be a breaking change for this crate. |
Unfortunately, this would indeed be a breaking ABI change in |
This is a UB bug, and as our UB diagnostics get better this might become a panic. Specifically, lines like this will panic. |
@RalfJung The UB isn't in this crate, though. It's in any crate that creates a zeroed I would love to fix this, but I don't see how that could be possible without breaking ABI. |
Fair. This crate makes it impossible to avoid the UB though.
Not sure how feasible that is, but there could be a new |
You can avoid the UB by setting the pointers to a valid value. You just can't set the pointers to NULL and rely on the defaults.
Interesting. Would it be UB to transmute a raw pointer to a |
Right. So you cannot use the entire zlib API (the defaults) and you cannot use
Raw pointers may point to anything, including nothing at all. They do not even have to be dereferencable, or aligned, or anything like that. That's their key reason to exist in my view -- to opt out of all the guarantees that come with references. You don't even need to transmute for that, you can just cast the raw pointer in safe code. And as you say that is okay as long as the NULL |
No description provided.
The text was updated successfully, but these errors were encountered: