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 error #16822

Closed
arturoc opened this issue Aug 28, 2014 · 5 comments · Fixed by #19780
Closed

compiler error #16822

arturoc opened this issue Aug 28, 2014 · 5 comments · Fixed by #19780
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

@arturoc
Copy link
Contributor

arturoc commented Aug 28, 2014

just updated rust to latest master and while trying to compile a program that was working before i'm getting:

error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'assertion failed: `(left == right) && (right == left)` (left: `12`, right: `0`)', /home/arturo/Code/rust/src/librustc/middle/ty.rs:2481

the code is rather large, i have tried to reproduce the error in a smaller example but can't find exactly where's the problem, it seems to be related with doing a borrow_mut() on a RefCell but as i said it doesn't happen on a smaller test

this is the backtrace:

stack backtrace:
   1:     0x2b92ca1e5630 - rt::backtrace::imp::write::h8e9eb4c0a425b5a5c0q
   2:     0x2b92ca1e8820 - failure::on_fail::h4325ba604d2e06acTlr
   3:     0x2b92c5d5c980 - unwind::begin_unwind_inner::h58dc61866064edc9Zie
   4:     0x2b92c5d5c620 - unwind::begin_unwind_fmt::hd2c2fac189295ad0pge
   5:     0x2b92c4ca3dd0 - middle::ty::type_contents::tc_ty::h25a65baa252c658f7yF
   6:     0x2b92c4ca3dd0 - middle::ty::type_contents::tc_ty::h25a65baa252c658f7yF
   7:     0x2b92c49f44d0 - middle::ty::type_contents::h9b457050afb365782xF
   8:     0x2b92c4c331b0 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::delegate_consume::h8962338896925635098
   9:     0x2b92c4c33810 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::consume_expr::h8571352652834906512
  10:     0x2b92c4c2d4a0 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h4231890686328975281
  11:     0x2b92c4c33810 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::consume_expr::h8571352652834906512
  12:     0x2b92c4c339e0 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_block::h4782883345545531812
  13:     0x2b92c4c2d4a0 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h4231890686328975281
  14:     0x2b92c4c37f50 - middle::trans::_match::create_bindings_map::h7016d3b670778ad74Th
  15:     0x2b92c4baf510 - middle::trans::_match::trans_match::hb6674054b0332fc8IPh
  16:     0x2b92c4b9a810 - middle::trans::expr::trans_rvalue_dps_unadjusted::h4885403a65bbadd16Q3
  17:     0x2b92c4b54980 - middle::trans::expr::trans_into::h5fa2aa27ba5f38abIs2
  18:     0x2b92c4b54f20 - middle::trans::controlflow::trans_block::hcf633bc09a595155wmY
  19:     0x2b92c4c0a8e0 - middle::trans::base::trans_closure::h6af85961afc5e10fvye
  20:     0x2b92c4b45950 - middle::trans::base::trans_fn::ha71ddc353381e3f5iKe
  21:     0x2b92c4b45fa0 - middle::trans::monomorphize::monomorphic_fn::hdc6c7b4578f922f8uJX
  22:     0x2b92c4b80bf0 - middle::trans::callee::trans_fn_ref_with_vtables::h98854ce341dfbb4ald1
  23:     0x2b92c4b7e2c0 - middle::trans::callee::trans_fn_ref::h1ee105fae6943b76tZ0
  24:     0x2b92c4ba38a0 - middle::trans::expr::trans_def::hdd427d1cdf1a3c95vH3
  25:     0x2b92c4b998b0 - middle::trans::expr::trans_unadjusted::h0e3e3a0f0810cd7eFh3
  26:     0x2b92c4b56150 - middle::trans::expr::trans::hb5d2106e56480123Ew2
  27:     0x2b92c4b91c60 - middle::trans::callee::trans_args::h64bca7f588848043aZ1
  28:     0x2b92c4b5e170 - middle::trans::callee::trans_call_inner::hde6eb414bb58985daE1
  29:     0x2b92c4b8c5f0 - middle::trans::callee::trans_method_call::h7e39c5fba92b93feoz1
  30:     0x2b92c4b9a810 - middle::trans::expr::trans_rvalue_dps_unadjusted::h4885403a65bbadd16Q3
  31:     0x2b92c4b54980 - middle::trans::expr::trans_into::h5fa2aa27ba5f38abIs2
  32:     0x2b92c4b53e30 - middle::trans::controlflow::trans_stmt_semi::h1da7aaaee12528e9ClY
  33:     0x2b92c4b53500 - middle::trans::controlflow::trans_stmt::he615239a63278692lhY
  34:     0x2b92c4b54f20 - middle::trans::controlflow::trans_block::hcf633bc09a595155wmY
  35:     0x2b92c4c0a8e0 - middle::trans::base::trans_closure::h6af85961afc5e10fvye
  36:     0x2b92c4b45950 - middle::trans::base::trans_fn::ha71ddc353381e3f5iKe
  37:     0x2b92c4b45fa0 - middle::trans::monomorphize::monomorphic_fn::hdc6c7b4578f922f8uJX
  38:     0x2b92c4b80bf0 - middle::trans::callee::trans_fn_ref_with_vtables::h98854ce341dfbb4ald1
  39:     0x2b92c4b7e2c0 - middle::trans::callee::trans_fn_ref::h1ee105fae6943b76tZ0
  40:     0x2b92c4b8bc50 - middle::trans::callee::trans_call::closure.115680
  41:     0x2b92c4b5e170 - middle::trans::callee::trans_call_inner::hde6eb414bb58985daE1
  42:     0x2b92c4b8b9e0 - middle::trans::callee::trans_call::h0243a778d0717798fy1
  43:     0x2b92c4b9a810 - middle::trans::expr::trans_rvalue_dps_unadjusted::h4885403a65bbadd16Q3
  44:     0x2b92c4b998b0 - middle::trans::expr::trans_unadjusted::h0e3e3a0f0810cd7eFh3
  45:     0x2b92c4b56150 - middle::trans::expr::trans::hb5d2106e56480123Ew2
  46:     0x2b92c4b91c60 - middle::trans::callee::trans_args::h64bca7f588848043aZ1
  47:     0x2b92c4b5e170 - middle::trans::callee::trans_call_inner::hde6eb414bb58985daE1
  48:     0x2b92c4b8c5f0 - middle::trans::callee::trans_method_call::h7e39c5fba92b93feoz1
  49:     0x2b92c4b9a810 - middle::trans::expr::trans_rvalue_dps_unadjusted::h4885403a65bbadd16Q3
  50:     0x2b92c4b54980 - middle::trans::expr::trans_into::h5fa2aa27ba5f38abIs2
  51:     0x2b92c4b53e30 - middle::trans::controlflow::trans_stmt_semi::h1da7aaaee12528e9ClY
  52:     0x2b92c4b53500 - middle::trans::controlflow::trans_stmt::he615239a63278692lhY
  53:     0x2b92c4b54f20 - middle::trans::controlflow::trans_block::hcf633bc09a595155wmY
  54:     0x2b92c4b55250 - middle::trans::controlflow::trans_if::h456ce55c98d730614oY
  55:     0x2b92c4b9a810 - middle::trans::expr::trans_rvalue_dps_unadjusted::h4885403a65bbadd16Q3
  56:     0x2b92c4b54980 - middle::trans::expr::trans_into::h5fa2aa27ba5f38abIs2
  57:     0x2b92c4b53e30 - middle::trans::controlflow::trans_stmt_semi::h1da7aaaee12528e9ClY
  58:     0x2b92c4b53500 - middle::trans::controlflow::trans_stmt::he615239a63278692lhY
  59:     0x2b92c4b54f20 - middle::trans::controlflow::trans_block::hcf633bc09a595155wmY
  60:     0x2b92c4c0a8e0 - middle::trans::base::trans_closure::h6af85961afc5e10fvye
  61:     0x2b92c4b45950 - middle::trans::base::trans_fn::ha71ddc353381e3f5iKe
  62:     0x2b92c4b40c90 - middle::trans::base::trans_item::hd7d78d670c61d953i2e
  63:     0x2b92c4c155b0 - middle::trans::base::trans_crate::hecf431b91ee08b4bJWf
  64:     0x2b92c4fe6eb0 - driver::driver::phase_4_translate_to_llvm::hcdd287bb9dda01e3pzy
  65:     0x2b92c4fde860 - driver::driver::compile_input::h48de06e93da98f07Qby
  66:     0x2b92c5070680 - driver::run_compiler::h8615fa3184fda61cJIB
  67:     0x2b92c5070590 - driver::main_args::closure.138206
  68:     0x2b92c5082820 - task::TaskBuilder<S>::try_future::closure.139324
  69:     0x2b92c5082620 - task::TaskBuilder<S>::spawn_internal::closure.139301
  70:     0x2b92c5abc660 - task::spawn_opts::closure.8369
  71:     0x2b92c5db57c0 - rust_try_inner
  72:     0x2b92c5db57b0 - rust_try
  73:     0x2b92c5d59fb0 - unwind::try::h188e044e161bf4e2f7d
  74:     0x2b92c5d59d70 - task::Task::run::hcf0d8d6cf4337bfazdd
  75:     0x2b92c5abc3c0 - task::spawn_opts::closure.8315
  76:     0x2b92c5d5bb70 - thread::thread_start::h0fac7ed375094744lCd
  77:     0x2b92caf8d0c0 - start_thread
  78:     0x2b92c6177359 - __clone
  79:                0x0 - <unknown>
@huonw
Copy link
Member

huonw commented Aug 28, 2014

I believe this may possibly be related to #16643. What version of rustc do you have?

@arturoc
Copy link
Contributor Author

arturoc commented Aug 28, 2014

rustc 0.12.0-pre (0d3bd77 2014-08-27 21:31:13 +0000)

@arturoc
Copy link
Contributor Author

arturoc commented Sep 2, 2014

i've managed to reproduce this with a simple example:

test.rs:

extern crate lib;

use std::cell::RefCell;

struct App{
    i: int
}

impl lib::Update for App{
    fn update(&mut self){
        self.i += 1;
    }
}

fn main(){
    let app = App{i: 5};
    let window = lib::Window{data: RefCell::new(app)};
    window.update(1);
}

lib.rs

#![crate_type = "lib"]
#![crate_name = "lib"]

use std::cell::RefCell;

pub struct Window<Data>{
    pub data: RefCell<Data>
}

impl<Data:  Update> Window<Data>{
    pub fn update(&self, e: i32){

        match e{
            1 => self.data.borrow_mut().update(),
            _ => {}
        }
    }
}

pub trait Update{
    fn update(&mut self);
}

the error seems to happen only when accessing a RefCell from a library instanciated with a type coming from a program linking to that library and only if the borrow is inside a match!, it doesn't seem to matter if the borrow is mutable or not.

@arturoc
Copy link
Contributor Author

arturoc commented Sep 2, 2014

here's the cargo files in case it helps to test:

[package]
name    = "test"
version = "0.1.0"
authors = []

[[bin]]
name = "test"
path = "test.rs"

[dependencies.lib]
path = "lib"
[package]
name    = "lib"
version = "0.1.0"
authors = []

[lib]
name = "lib"
path = "lib.rs"

@arturoc
Copy link
Contributor Author

arturoc commented Oct 6, 2014

just git bissected this and seems like the buggy commit is one of:
5dca9fb
71df8e6

@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 11, 2014
bors added a commit that referenced this issue Dec 18, 2014
Closes #5988.
Closes #10176.
Closes #10456.
Closes #12744.
Closes #13264.
Closes #13324.
Closes #14182.
Closes #15381.
Closes #15444.
Closes #15480.
Closes #15756.
Closes #16822.
Closes #16966.
Closes #17351.
Closes #17503.
Closes #17545.
Closes #17771.
Closes #17816.
Closes #17897.
Closes #17905.
Closes #18188.
Closes #18232.
Closes #18345.
Closes #18389.
Closes #18400.
Closes #18502.
Closes #18611.
Closes #18783.
Closes #19009.
Closes #19081.
Closes #19098.
Closes #19127.
Closes #19135.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 31, 2024
fix: Make inlay hint resolving work better for inlays targetting the same position
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

Successfully merging a pull request may close this issue.

3 participants