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

Possible unaligned write with MutableBuffer::push #1410

Closed
jhorstmann opened this issue Mar 9, 2022 · 0 comments · Fixed by #1421
Closed

Possible unaligned write with MutableBuffer::push #1410

jhorstmann opened this issue Mar 9, 2022 · 0 comments · Fixed by #1421
Labels
arrow Changes to the arrow crate bug

Comments

@jhorstmann
Copy link
Contributor

The following test fails when run under miri:

    #[test]
    fn mutable_push_unaligned_u64() {
        let mut buf = MutableBuffer::new(16);
        buf.push(1_u8);
        buf.push(1_u64);
        assert_eq!(9, buf.len());
        assert_eq!(&[1u8, 1u8, 0, 0, 0, 0, 0, 0, 0], buf.as_slice());
    }

The code uses std::ptr::write to append the u64, regardless of the current alignment. Replacing that with write_unaligned would probably work. The type parameter is constrained by the ToByteSlice trait, but it seems the trait is not actually used. Not sure whether this is expected. It seems ToByteSlice is more of a marker trait here that indicates that the contents can be transmuted to a slice of bytes.

@jhorstmann jhorstmann added the bug label Mar 9, 2022
@alamb alamb added the arrow Changes to the arrow crate label Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants