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

Assertion failed (Calling a function with a bad signature) in dead code #15484

Closed
gmorenz opened this issue Jul 6, 2014 · 2 comments
Closed
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@gmorenz
Copy link

gmorenz commented Jul 6, 2014

Sorry about not reducing this more, gl is https://github.com/bjz/gl-rs

extern crate gl;

use std::mem;

use gl::types::GLsizeiptr;
use gl::types::GLuint;

#[allow(unreachable_code)]
fn main() {

    return;

    let elements: [GLuint, .. 1 * 6] = [
        0, 1, 2,
        2, 3, 0,
    ];

    unsafe {
        gl::BufferData(gl::ELEMENT_ARRAY_BUFFER,
                       (elements.len() * mem::size_of::<GLuint>()) as GLsizeiptr,
                       mem::transmute(&elements[0]),
                       gl::STATIC_DRAW);
    }
}

Compiler output:

$ RUST_BACKTRACE=1 rustc src/main.rs -L target/deps
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-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.
Aborted (core dumped)

Since that doesn't get a backtrace, gdb output:

$ gdb --args rustc src/main.rs -L target/deps
GNU gdb (GDB) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from rustc...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/local/bin/rustc src/main.rs -L target/deps
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff0bff480 (LWP 18366)]
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-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.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff0bff480 (LWP 18366)]
0x00007ffff478bd67 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff478bd67 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff478d118 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff4784bdd in __assert_fail_base () from /usr/lib/libc.so.6
#3  0x00007ffff4784c92 in __assert_fail () from /usr/lib/libc.so.6
#4  0x00007ffff688914e in llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) ()
   from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#5  0x00007ffff5b3ccf9 in llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >::CreateCall(llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) ()
   from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#6  0x00007ffff67ea936 in LLVMBuildCall ()
   from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#7  0x00007ffff52b3d69 in middle::trans::builder::Builder$LT$$x27a$GT$::call::h0398c24efef6defbPvo::v0.11.0 ()
   from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#8  0x00007ffff5227a56 in middle::trans::base::invoke::he436b450ee496508yJp::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#9  0x00007ffff523f425 in middle::trans::callee::trans_call_inner::hdfdb8c30fa124095R1e::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#10 0x00007ffff5244b08 in middle::trans::callee::trans_call::h9df70b3aef437bdcZVe::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#11 0x00007ffff524f6e9 in middle::trans::expr::trans_rvalue_dps_unadjusted::hf749359ec6e2a160hvg::v0.11.0 ()
   from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#12 0x00007ffff520a7b8 in middle::trans::expr::trans_into::hf0a37465b961389bIDf::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#13 0x00007ffff5209989 in middle::trans::controlflow::trans_stmt_semi::h60648583663979489hc::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#14 0x00007ffff520914b in middle::trans::controlflow::trans_stmt::h136741cd3736231fMdc::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#15 0x00007ffff520abb1 in middle::trans::controlflow::trans_block::hecc22008fef2a1bd2ic::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#16 0x00007ffff524f2b3 in middle::trans::expr::trans_rvalue_dps_unadjusted::hf749359ec6e2a160hvg::v0.11.0 ()
   from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#17 0x00007ffff520a7b8 in middle::trans::expr::trans_into::hf0a37465b961389bIDf::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#18 0x00007ffff520ac89 in middle::trans::controlflow::trans_block::hecc22008fef2a1bd2ic::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#19 0x00007ffff52ce43a in middle::trans::base::trans_closure::h639d28c7bc97ae139tq::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#20 0x00007ffff51db8a6 in middle::trans::base::trans_fn::he5cf57c39474f14caCq::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#21 0x00007ffff51d4ebe in middle::trans::base::trans_item::h17204c67e6746031BSq::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#22 0x00007ffff52deab1 in middle::trans::base::trans_crate::hfddcc2510b7c9311IMr::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#23 0x00007ffff5a036cf in driver::driver::phase_4_translate_to_llvm::h6b5f55c3e1863d4cTuq::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#24 0x00007ffff59fb9ea in driver::driver::compile_input::hc5634315c7a145c8n8p::v0.11.0 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#25 0x00007ffff5ab0723 in driver::run_compiler::hae575e8dc5c8f87dVTs::v0.11.0
    () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#26 0x00007ffff5aadeb5 in driver::main_args::closure.117607 ()
   from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#27 0x00007ffff5ac2058 in task::TaskBuilder$LT$S$GT$::try_future::closure.118749---Type <return> to continue, or q <return> to quit---continue
 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#28 0x00007ffff5ac1f2c in task::TaskBuilder$LT$S$GT$::spawn_internal::closure.118726 () from /usr/local/bin/../lib/librustc-a9826c4a-0.11.0.so
#29 0x00007ffff7ba7f88 in task::spawn_opts::closure.7519 ()
   from /usr/local/bin/../lib/libnative-35e04b6f-0.11.0.so
#30 0x00007ffff4bd01bc in rust_try ()
   from /usr/local/bin/../lib/librustrt-805dca70-0.11.0.so
#31 0x00007ffff4b742d6 in unwind::try::hd5f4c2617b203e57BNd::v0.11.0 ()
   from /usr/local/bin/../lib/librustrt-805dca70-0.11.0.so
#32 0x00007ffff4b74050 in task::Task::run::headae25e22673ff0XYc::v0.11.0 ()
   from /usr/local/bin/../lib/librustrt-805dca70-0.11.0.so
#33 0x00007ffff7ba7e11 in task::spawn_opts::closure.7465 ()
   from /usr/local/bin/../lib/libnative-35e04b6f-0.11.0.so
#34 0x00007ffff4b76b14 in thread::thread_start::hf8076cce1f95d94cvld::v0.11.0
    () from /usr/local/bin/../lib/librustrt-805dca70-0.11.0.so
#35 0x00007ffff3e38124 in start_thread () from /usr/lib/libpthread.so.0
#36 0x00007ffff48414bd in clone () from /usr/lib/libc.so.6
(gdb) quit

If the return is removed from the source code, this compiles fine.

@steveklabnik
Copy link
Member

Today, I get this:

rustc: /home/steve/src/rust/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 `foo`.

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

No longer ICEs.

extern crate gl;

use std::mem;

use gl::types::GLsizeiptr;
use gl::types::GLuint;

#[allow(unreachable_code)]
fn main() {

    return;

    let elements: [GLuint; 6] = [
        0, 1, 2,
        2, 3, 0,
    ];

    unsafe {
        gl::BufferData(gl::ELEMENT_ARRAY_BUFFER,
                       (elements.len() * mem::size_of::<GLuint>()) as GLsizeiptr,
                       mem::transmute(&elements[0]),
                       gl::STATIC_DRAW);
    }
}

compiles without issue.

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 21, 2015
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2023
…=Veykril

feat: Bool to enum assist

This adds the `bool_to_enum` assist, which converts the type of boolean local variables, fields, constants and statics to a new `enum` type, making it easier to distinguish the meaning of `true` and `false` by renaming the variants.

Closes rust-lang#14779
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants