-
Notifications
You must be signed in to change notification settings - Fork 761
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
offset_of is unsound #1483
Comments
I think we can use |
Note that |
|
I must have misunderstood; I thought you meant to use mio/src/sys/windows/named_pipe.rs Line 28 in 1667a70
That would still be wrong. |
As far as I know the I was thinking something along the following lines: let inner: Inner = // ...
let offset = std::ptr::addr_of!(inner.read) as usize - (&inner as *const _ as usize);
Arc::from_raw(($e as usize - offset) as *mut $t) |
I'm saying you cannot do If you have an existing instance of |
The macro at
mio/src/sys/windows/named_pipe.rs
Line 26 in 1667a70
*
on a NULL pointer. See the reference for details.The memoffset crate provides a version of this macro that avoids UB (on older versions of rustc, this is not always possible, so it falls back to the 'least incorrect' version when needed).
The text was updated successfully, but these errors were encountered: