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

Incorrect codegen with unsized types on 32-bit Windows #30051

Closed
alexcrichton opened this issue Nov 25, 2015 · 1 comment
Closed

Incorrect codegen with unsized types on 32-bit Windows #30051

alexcrichton opened this issue Nov 25, 2015 · 1 comment
Labels
A-codegen Area: Code generation O-windows Operating system: Windows O-x86_32 Target: x86 processors, 32 bit (like i686-*)

Comments

@alexcrichton
Copy link
Member

This seems like quite a mysterious bug to me, the code below will compile and run successfully on 32-bit OSX/Linux as well as 64-bit OSX/Linux/Windows. It will fail, however, on 32-bit Windows (both GNU and MSVC toolchains). I'm not 100% sure that this is actually a codegen issue, but it's the only thing I can think of unfortunately.

Specifically, the assertion below will fail with some unusually corrupt value in self.0 (e.g. it changes over time).

struct Foo(u64);
struct Bar<T: ?Sized>(u32, T);

trait Trait {
        fn foo(&self);
}

impl Trait for Foo {
        fn foo(&self) {
                assert_eq!(self.0, 0);
        }
}


fn main() {
        let cursor = Foo(0);
        let ar = Bar(32, cursor);
        let ar: &Bar<Trait> = &ar;
        ar.1.foo();
}

This may just be a dupe of #26403, but the failure only on 32-bit Windows seems quite suspicious to me. This is reduced down from the test suite of tar-rs segfaulting on windows.

@alexcrichton alexcrichton added O-windows Operating system: Windows A-codegen Area: Code generation A-x86 labels Nov 25, 2015
@alexcrichton
Copy link
Member Author

Aha, looks like this is a dupe of #26403. On Windows the alignment of u64 is 8, but on Linux it's 4 which is why I only saw it on Windows and why it didn't show up for 32-bit Linux. On 64-bit linux the above test also fails (because the align of Foo is higher than that of the first field in Bar).

@Noratrieb Noratrieb added O-x86_32 Target: x86 processors, 32 bit (like i686-*) and removed O-x86-all labels Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation O-windows Operating system: Windows O-x86_32 Target: x86 processors, 32 bit (like i686-*)
Projects
None yet
Development

No branches or pull requests

2 participants