Skip to content

UB in hdf5_types::impl_tuple! macro #304

@1c3t3a

Description

@1c3t3a

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions