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

LLVM assertion when calling std::mem::align_of() on recursive struct with fixed-size vec #19001

Closed
michaelwoerister opened this issue Nov 16, 2014 · 14 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

Comments

@michaelwoerister
Copy link
Member

Example program:

use std::mem;

struct AlignmentStruct {
    ptr: *mut [AlignmentStruct, ..1]
}

fn main() {
    println!("{}", ::std::mem::align_of::<AlignmentStruct>());
}

Error message:

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/lib/IR/DataLayout.cpp:636: unsigned int llvm::DataLayout::getAlignment(llvm::Type*, bool) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.
@michaelwoerister michaelwoerister added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Nov 16, 2014
@DavidJFelix
Copy link

I just received this same error when using the following:

use std::rc::Rc;

struct Test {
    children: [Option<Rc<Test>>; 8],
}

impl Test {
    fn get_child() -> Option<Rc<Test>> {
        None
    }
}

I tried to reduce the code as much as possible and still get the error.

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

No longer ICEs. Both examples compile without error:

use std::mem;

struct AlignmentStruct {
    ptr: *mut [AlignmentStruct; 1]
}

fn main() {
    println!("{}", ::std::mem::align_of::<AlignmentStruct>());
}
use std::rc::Rc;

struct Test {
    children: [Option<Rc<Test>>; 8],
}

impl Test {
    fn get_child() -> Option<Rc<Test>> {
        None
    }
}

fn main() {
    // Add code here
}

@steveklabnik
Copy link
Member

I get a strange error for the first:

hello.rs:1:5: 1:13 warning: unused import, #[warn(unused_imports)] on by default
hello.rs:1 use std::mem;
               ^~~~~~~~
hello.rs:4:9: 4:39 warning: struct field is never used: `ptr`, #[warn(dead_code)] on by default
hello.rs:4         ptr: *mut [AlignmentStruct; 1]
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/DataLayout.cpp:655: unsigned int llvm::DataLayout::getAlignment(llvm::Type*, bool) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.

hello.rs:1:5: 1:13 warning: unused import, #[warn(unused_imports)] on by default
hello.rs:1 use std::mem;
               ^~~~~~~~
hello.rs:4:9: 4:39 warning: struct field is never used: `ptr`, #[warn(dead_code)] on by default
hello.rs:4         ptr: *mut [AlignmentStruct; 1]
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/DataLayout.cpp:655: unsigned int llvm::DataLayout::getAlignment(llvm::Type*, bool) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.

and the second both.

@steveklabnik steveklabnik added I-wrong and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 22, 2015
@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

$ rustc --version
rustc 1.0.0-dev (f46c4e158 2015-04-20) (built 2015-04-20)

@steveklabnik what do you have?

@steveklabnik
Copy link
Member

$ rustc --version
rustc 1.0.0-nightly (f46c4e158 2015-04-20) (built 2015-04-21)

@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

@steveklabnik could yours have been built against a different LLVM version? cc @alexcrichton because I don't know how the buildbots do their thing

@steveklabnik
Copy link
Member

I'm just doing whatever multirust installed.

@alexcrichton
Copy link
Member

@tamird this probably has to do with LLVM assertions being disabled by default in nightly

@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2015

still an issue on 1.4.

@apasel422
Copy link
Contributor

This appears to compile successfully now.

@dotdash
Copy link
Contributor

dotdash commented Oct 26, 2015

Still hits an LLVM assertion with the latest nightly for me.

@apasel422 stable and beta builds have LLVM assertions disabled, so you can't reproduce with those.

@apasel422
Copy link
Contributor

Hmm, I just built from source with LLVM assertions enabled and it appeared
to work.

On Monday, October 26, 2015, Björn Steinbrink [email protected]
wrote:

Still hits an LLVM assertion with the latest nightly for me.

@apasel422 https://github.com/apasel422 stable and beta builds have
LLVM assertions disabled, so you can't reproduce with those.


Reply to this email directly or view it on GitHub
#19001 (comment).

@dotdash
Copy link
Contributor

dotdash commented Oct 26, 2015

I'll try with a local build once it finished.

And I forgot to mention that only the second example given by @tamird still fails for me. The first one works fine.

@apasel422
Copy link
Contributor

Yes, that example by @tamird continues to fail.

arielb1 added a commit to arielb1/rust that referenced this issue Oct 27, 2015
when evaluating a recursive type, the type_of of the interior could be
still in progress, so we can't use that.

Fixes rust-lang#19001
bors added a commit that referenced this issue Oct 28, 2015
when evaluating a recursive type, the `type_of` of the interior could be
still in progress, so trying to get its size would cause an ICE.

Fixes #19001

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
Projects
None yet
Development

No branches or pull requests

8 participants