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

Compiler crashed with 'Calling a function with a bad signature!' #22874

Closed
jamii opened this issue Feb 27, 2015 · 8 comments
Closed

Compiler crashed with 'Calling a function with a bad signature!' #22874

jamii opened this issue Feb 27, 2015 · 8 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@jamii
Copy link

jamii commented Feb 27, 2015

#![feature(hash)] // TODO is this a good idea?
#![allow(dead_code)]

#[derive(PartialOrd, PartialEq, Clone, Hash, Debug)]
enum Value {
    Least,
    String(String),
    Greatest
}

type Row = [Value];

struct Table {
    rows: [Row]
}

trait Skippable {
    fn next(&self, row: &Row, inclusive: bool) -> &Row;
}

impl Skippable for Table {
    fn next(&self, row: &Row, inclusive: bool) -> &Row {
        &self.rows[0]
    }
}

fn main() {
}
amie@wanderer:~/make_you_a_database/examples$ cargo build --verbose
   Compiling make-you-a-database v0.0.1 (file:///home/jamie/make_you_a_database/examples)
     Running `rustc src/main.rs --crate-name make-you-a-database --crate-type bin -g --out-dir /home/jamie/make_you_a_database/examples/target --emit=dep-info,link -L dependency=/home/jamie/make_you_a_database/examples/target -L dependency=/home/jamie/make_you_a_database/examples/target/deps`
src/main.rs:1:12: 1:16 warning: unused or unknown feature, #[warn(unused_features)] on by default
src/main.rs:1 #![feature(hash)] // TODO is this a good idea?
                         ^~~~
src/main.rs:22:17: 22:20 warning: unused variable: `row`, #[warn(unused_variables)] on by default
src/main.rs:22  fn next(&self, row: &Row, inclusive: bool) -> &Row {
                               ^~~
src/main.rs:22:28: 22:37 warning: unused variable: `inclusive`, #[warn(unused_variables)] on by default
src/main.rs:22  fn next(&self, row: &Row, inclusive: bool) -> &Row {
                                          ^~~~~~~~~
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:281: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
Could not compile `make-you-a-database`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name make-you-a-database --crate-type bin -g --out-dir /home/jamie/make_you_a_database/examples/target --emit=dep-info,link -L dependency=/home/jamie/make_you_a_database/examples/target -L dependency=/home/jamie/make_you_a_database/examples/target/deps` (status=6)
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 27, 2015
@zofrex
Copy link
Contributor

zofrex commented Feb 28, 2015

I've made an attempt at removing as much code that doesn't affect the outcome as possible:

#![allow(dead_code)]

enum Value {
    String(String)
}

type Row = [Value];

struct Table {
    rows: [Row]
}

impl Table {
    fn next(&self) -> &Row {
        &self.rows[0]
    }
}

fn main() {
}
Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/llvm/lib/IR/Instructions.cpp, line 281.
Abort trap: 6

@frewsxcv
Copy link
Member

I reduced this even further:

#![allow(dead_code)]

enum Value {
    A(String)
}

struct Table {
    rows: [[Value]]
}

impl Table {
    fn next(&self) {
        &self.rows[0];
    }
}

fn main() {}

This is still an issue with Rust 1.0 beta 2

~/Downloads $ rustc test.rs
Call parameter type does not match function signature!
  %6 = phi %Value* [ %3, %entry-block ], [ %8, %iter_vec_loop_body ]
 { %Value*, i64 }*  call void @"_ZN16_$u5b$Value$u5d$8drop.95817h5f8aee98e1349761E"(%Value* %6)
LLVM ERROR: Broken function found, compilation aborted!

~/Downloads $ rustc --version
rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)

@murarth
Copy link
Contributor

murarth commented Jun 14, 2015

I was able to get the same failed assertion with a much smaller piece of code:

trait Foo {}
fn main() {
    let _a: [Foo; 0];
}
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:281: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.

@theemathas
Copy link
Contributor

Related to #21748

@randomPoison
Copy link
Contributor

This bug is still happening in the 10/18/2015 nightly build.

wheals added a commit to wheals/glacier that referenced this issue Oct 26, 2015
@pmarcelll
Copy link
Contributor

This seems to be fixed.
@steveklabnik this can be removed from Glacier, it's just a regular error now.

@petrochenkov
Copy link
Contributor

Fixed in Rust 1.2

Minimized:

struct Table {
    rows: [[String]]
}

fn f(table: &Table) -> &[String] {
    &table.rows[0]
}

fn main() {}

Needs test.

@petrochenkov petrochenkov added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Mar 5, 2017
@mattico
Copy link
Contributor

mattico commented Mar 10, 2017

This can be closed now that #40296 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

10 participants