Skip to content

pthread_attr_t definition is incorrect, will cause unaligned memory accesses #10300

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
thestinger opened this issue Nov 5, 2013 · 4 comments
Closed
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state

Comments

@thestinger
Copy link
Contributor

It's not correct to bind a union in Rust as an array of bytes. The alignment of a byte array is always 1.

struct Foo {
    xs: [u8, ..64]
}

fn main() {
    println!("{}", std::mem::min_align_of::<Foo>())
}

x86 allows unaligned memory accesses, but other architectures are not as forgiving.

@thestinger
Copy link
Contributor Author

This was implemented by 47e0bd4, but I don't think it's possible to correctly express this in Rust until we have either a way to specify minimum alignment or a direct analogy to union.

@thestinger
Copy link
Contributor Author

cc @alexcrichton

@alexcrichton
Copy link
Member

Hm, it is kinda nice having these defined in rust instead of having to malloc them. Do you know if we change the to all just [u64, ..N] if things would be ok? Or would this want some sort of #[align] attribute?

@thestinger
Copy link
Contributor Author

Building them out of a combination of u64 and u32 would work.

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 28, 2023
Do not lint when imported item contains underscore

fix rust-lang/rust-clippy#9942

changelog: [`wildcard_imports`]: No longer lints when imported items contain an item with the name `_`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants