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

Valgrind complains about uninitialized memory in buffer returned by read_at_aligned #647

Open
vlovich opened this issue Apr 11, 2024 · 0 comments

Comments

@vlovich
Copy link
Contributor

vlovich commented Apr 11, 2024

I'm getting a lot of Valgrind errors accessing the ReadResult after a read_at_aligned in DmaFile:

Conditional jump or move depends on uninitialised value(s)

and

Use of uninitialised value of size 8

I'm currently working around this by adding a dependency on crabgrind & explicitly annotating the memory as defined. This is probably a bug (or inherent limitation) in Valgrind, but just in case this is fixable within glommio (e.g. by initializing the memory with 0s when it's allocated?).

Repro:

use glommio::io::OpenOptions;

fn main() {
    glommio::LocalExecutor::default().run(async move {
        let file = OpenOptions::new().tmpfile(true).read(true).write(true).dma_open("/tmp/").await.expect("couldn't open file");
        let mut buf = file.alloc_dma_buffer(4096);
        let mut idx = 0usize;
        buf.as_bytes_mut().fill_with(|| {idx += 1; idx as u8});
        file.write_at(buf, 0).await.expect("failed to write buffer");

        let read = file.read_at_aligned(0, 512).await.expect("failed to read buffer");
        let sum = read.iter().map(|&b| b as usize).sum::<usize>();
        assert_eq!(sum, 65280);

        let read = file.read_at_aligned(512, 4096).await.expect("failed to read buffer");
        assert_eq!(read.len(), 3584);
        let sum = read.iter().map(|&b| b as usize).sum::<usize>();
        assert_eq!(sum, 456960);
    });
}

repro.zip

Upstream: https://bugs.kde.org/show_bug.cgi?id=485400

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