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

UB in hdf5_types::impl_tuple! macro #304

Open
1c3t3a opened this issue Jan 28, 2025 · 0 comments
Open

UB in hdf5_types::impl_tuple! macro #304

1c3t3a opened this issue Jan 28, 2025 · 0 comments

Comments

@1c3t3a
Copy link

1c3t3a commented Jan 28, 2025

Hello hdf5-rust maintainers,

I am working on a compiler patch that automatically inserts checks for null pointers and null-backed references in debug mode (rust-lang/rust#134424). As part of my change I noticed that it breaks your crates' test-suite.

As part of the hdf5_types::imple_tuple! macro you create a reference backed by a null pointer, which is UB. The related code snippet is this one: https://github.com/aldanor/hdf5-rust/blob/master/hdf5-types/src/h5type.rs#L287-L332 and the line containing the problem is let &$($s)*(.., ref f, $(impl_tuple!(@second $tt _),)*) = unsafe { &*$origin };.

For more on why this is instant UB, please see the discussion here.

Please note that the tests will start failing as soon as this is enabled in the compiler. This is just a heads-up!

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

No branches or pull requests

1 participant