Skip to content

Compilation fails without error message #41139

Description

@memoryleak47

This rust code fails in compilation without error message:

trait Trait {}

fn get_function<'a>() -> &'a Fn() -> Trait { panic!("") }

fn main() {
        let t : &Trait = &get_function()();
}

When compiling with cargo build --verbose I get:

   Compiling errroom v0.1.0 (file:///home/memoryleak47/projects/mind/srl/lawsets/b.3/errroom)
     Running `rustc --crate-name errroom main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=23eb45247c97d4cd -C extra-filename=-23eb45247c97d4cd --out-dir /home/memoryleak47/projects/mind/srl/lawsets/b.3/errroom/target/debug/deps -L dependency=/home/memoryleak47/projects/mind/srl/lawsets/b.3/errroom/target/debug/deps`
warning: unused variable: `t`, #[warn(unused_variables)] on by default
 --> main.rs:6:6
  |
6 | 	let t : &Trait = &get_function()();
  | 	    ^

error: Could not compile `errroom`.

Caused by:
  process didn't exit successfully: `rustc --crate-name errroom main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=23eb45247c97d4cd -C extra-filename=-23eb45247c97d4cd --out-dir /home/memoryleak47/projects/mind/srl/lawsets/b.3/errroom/target/debug/deps -L dependency=/home/memoryleak47/projects/mind/srl/lawsets/b.3/errroom/target/debug/deps` (exit code: 1)

rustc --version --verbose:

rustc 1.16.0 (30cf806ef 2017-03-10)
binary: rustc
commit-hash: 30cf806ef8881c41821fbd43e5cf3699c5290c16
commit-date: 2017-03-10
host: x86_64-unknown-linux-gnu
release: 1.16.0
LLVM version: 3.9

Activity

  1. jonas-schievink commented on Apr 7, 2017

    @jonas-schievink
    Contributor

    According to the Playpen, this actually segfaults the compiler (on all channels). Doing a Release build reveals why (on stable and beta):

    Incorrect number of arguments passed to called function!
      invoke void @_ZN4drop17hd8e1ea93099f8185E(i8* %8)
              to label %bb3 unwind label %cleanup
    LLVM ERROR: Broken function found, compilation aborted!
    

    On nightly, the error is different (since LLVM assertions are enabled, even though they don't catch the error in debug builds):

    rustc: /checkout/src/llvm/include/llvm/Support/Casting.h:95: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::Constant; From = llvm::Value]: Assertion `Val && "isa<> used on a null pointer"' failed.
    Aborted (core dumped)
    
  2. added
    I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-codegenArea: Code generation
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    on Apr 7, 2017
  3. TimNN commented on Apr 7, 2017

    @TimNN
    Contributor

    This is a regression form 1.11 to 1.12, likely introduced by mir -- 1.12 + -Zorbit=off doesn't reproduce.

  4. TimNN commented on Apr 7, 2017

    @TimNN
    Contributor

    Backtrace on nightly:

    #3  0x00007f2d7175ec62 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
    #4  0x00007f2d6baaaee6 in llvm::cast_retty<llvm::Constant, llvm::Value*>::ret_type llvm::dyn_cast<llvm::Constant, llvm::Value>(llvm::Value*) ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_llvm-3aedc27cea629d08.so
    #5  0x00007f2d6ca47371 in LLVMBuildInBoundsGEP () from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_llvm-3aedc27cea629d08.so
    #6  0x00007f2d712890fa in rustc_trans::builder::Builder::gepi ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #7  0x00007f2d712ba6d2 in rustc_trans::meth::VirtualIndex::get_fn ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #8  0x00007f2d712c4155 in rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_block ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #9  0x00007f2d712bf0d1 in rustc_trans::mir::trans_mir () from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #10 0x00007f2d712e33dd in rustc_trans::trans_item::TransItem::define ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #11 0x00007f2d7127f74e in rustc_trans::base::trans_crate::trans_def_task ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #12 0x00007f2d7122b85b in rustc::dep_graph::graph::DepGraph::with_task ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #13 0x00007f2d71279f7b in rustc_trans::base::trans_crate ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/librustc_trans-8524c596fdbfd5aa.so
    #14 0x00007f2d71f7f97a in rustc_driver::driver::phase_4_translate_to_llvm ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-0f4024af7b82b2df.so
    #15 0x00007f2d71f3df49 in rustc_driver::driver::compile_input::{{closure}} ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-0f4024af7b82b2df.so
    #16 0x00007f2d71f6c8e6 in rustc_driver::driver::phase_3_run_analysis_passes::{{closure}} ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-0f4024af7b82b2df.so
    #17 0x00007f2d71eada73 in rustc::ty::context::TyCtxt::create_and_enter ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-0f4024af7b82b2df.so
    #18 0x00007f2d71f5a9bf in rustc_driver::driver::phase_3_run_analysis_passes ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-0f4024af7b82b2df.so
    #19 0x00007f2d71f33e80 in rustc_driver::driver::compile_input ()
       from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-0f4024af7b82b2df.so
    #20 0x00007f2d71f93d8c in rustc_driver::run_compiler () from /home/logic/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-0f4024af7b82b2df.so
    
  5. arielb1 commented on Apr 7, 2017

    @arielb1
    Contributor

    This is not supposed to compile. We are taking a reference to an unsized rvalue, which is silly.

  6. added a commit that references this issue on Apr 11, 2017
    0144613
  7. added 3 commits that reference this issue on Feb 5, 2025
  8. added a commit that references this issue on Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions