Skip to content

ICE: the 1th autoderef failed #28347

@mathstuf

Description

@mathstuf

ICE when using Rc<RefCell<Box<FnMut()>>>.

use std::rc::Rc;
use std::cell::RefCell;

fn main() {
    let mut a = 0;
    let fs = vec![Rc::new(RefCell::new(Box::new(|| a = 4 )))];

    fs.iter().map(|f| {
        let mut closure = f.borrow_mut();
        (&mut *closure)()
    });
}

rustc --version --verbose:

rustc 1.2.0 (082e47636 2015-08-03)
binary: rustc
commit-hash: 082e4763615bdbe7b4dd3dfd6fc2210b7773edf5
commit-date: 2015-08-03
host: x86_64-unknown-linux-gnu
release: 1.2.0

Backtrace:

test.rs:10:9: 10:24 error: internal compiler error: the 1th autoderef failed: _
test.rs:10         (&mut *closure)()
                   ^~~~~~~~~~~~~~~
note: in expansion of closure expansion
test.rs:8:19: 11:6 note: expansion site
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176

stack backtrace:
   1:     0x7f6acb0e8c4e - sys::backtrace::write::h31b60a04d5b9a81ckqs
   2:     0x7f6acb0f0af4 - panicking::on_panic::haca2ec19b0bb0f31B8w
   3:     0x7f6acb0b363e - rt::unwind::begin_unwind_inner::h384bd76ff13d8e66fOw
   4:     0x7f6ac845426c - rt::unwind::begin_unwind::h14103907744675915507
   5:     0x7f6ac845420b - diagnostic::SpanHandler::span_bug::h72882058eb962965T4A
   6:     0x7f6ac8f43328 - session::Session::span_bug::hfa5b291f1709fe92Rqt
   7:     0x7f6aca8552a8 - check::FnCtxt<'a, 'tcx>::adjust_expr_ty::hcd093ab3a40f5bb6Nop
   8:     0x7f6aca87799f - check::FnCtxt<'a, 'tcx>.mc..Typer<'tcx>::expr_ty_adjusted::h3c0af9c15ed6f424qAn
   9:     0x7f6aca87add7 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::walk_expr::h6216850097559692141
  10:     0x7f6aca87c5f4 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::consume_expr::h113780211265301586
  11:     0x7f6aca87b7b9 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::walk_expr::h6216850097559692141
  12:     0x7f6aca87c5f4 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::consume_expr::h113780211265301586
  13:     0x7f6aca87642d - check::upvar::AdjustBorrowKind<'a, 'tcx>::analyze_closure::hb99b4433fcedd921bLj
  14:     0x7f6aca875346 - visit::walk_expr::h4780249156801623522
  15:     0x7f6aca875191 - visit::walk_expr::h4780249156801623522
  16:     0x7f6aca874a2b - visit::walk_block::h12255223039637640698
  17:     0x7f6aca8a771f - check::check_bare_fn::h88c035244660e365WMn
  18:     0x7f6aca8a54c3 - check::check_item_body::h9873e3da412bca20ydo
  19:     0x7f6aca8a7184 - check::check_item_types::h63240bfbe991be87tKn
  20:     0x7f6aca962f88 - check_crate::hc77ba823ce7b03a29fD
  21:     0x7f6acb64c549 - driver::phase_3_run_analysis_passes::closure.15761
  22:     0x7f6acb64a9da - middle::ty::with_ctxt::h13439206479737651595
  23:     0x7f6acb645797 - driver::phase_3_run_analysis_passes::h6776952700745527488
  24:     0x7f6acb627ff6 - driver::compile_input::h68c27ba828e71325Tba
  25:     0x7f6acb704af3 - run_compiler::h21d74b88eec3fe3bx7b
  26:     0x7f6acb7024ce - boxed::F.FnBox<A>::call_box::h494796883951262272
  27:     0x7f6acb701d19 - rt::unwind::try::try_fn::h457431378832593386
  28:     0x7f6acb168e58 - rust_try_inner
  29:     0x7f6acb168e45 - rust_try
  30:     0x7f6acb0dbec7 - rt::unwind::try::inner_try::h472293c152f3b97e8Jw
  31:     0x7f6acb701f2b - boxed::F.FnBox<A>::call_box::h791391859944982395
  32:     0x7f6acb0ef751 - sys::thread::Thread::new::thread_start::hed666015e7925bf95Tv
  33:     0x7f6ac574f6c9 - start_thread
  34:     0x7f6acad4199c - __clone
  35:                0x0 - <unknown>

Latest nightly I have laying around:

rustc 1.4.0-dev (bc3573470 2015-08-24)
binary: rustc
commit-hash: bc3573470f009fa078fe063700b8df2854e8499e
commit-date: 2015-08-24
host: x86_64-unknown-linux-gnu
release: 1.4.0-dev
test.rs:10:9: 10:24 error: internal compiler error: the 1th autoderef failed: _
test.rs:10         (&mut *closure)()
                   ^~~~~~~~~~~~~~~
note: in expansion of closure expansion
test.rs:8:19: 11:6 note: expansion site
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Box<Any>', ../src/src/libsyntax/diagnostic.rs:176

stack backtrace:
   1:     0x7f2f01b035d9 - sys::backtrace::tracing::imp::write::h3114d66e46af15a1yes
   2:     0x7f2f01b0b316 - panicking::on_panic::h159c4a1fdfbb3c4aqfx
   3:     0x7f2f01ad141e - rt::unwind::begin_unwind_inner::h7a4d429f5f5ed1ca4Hw
   4:     0x7f2efeabad27 - rt::unwind::begin_unwind::h230502335082064076
   5:     0x7f2efeabace6 - diagnostic::SpanHandler::span_bug::h6c6f7efd0101f1f57IA
   6:     0x7f2effba80ba - middle::infer::InferCtxt<'a, 'tcx>::adjust_expr_ty::hacce860cf1ee2f9f5hD
   7:     0x7f2effb1afdb - middle::infer::InferCtxt<'a, 'tcx>::expr_ty_adjusted::h3e6a3fba33ae2dd9SDD
   8:     0x7f2effaefa30 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_expr::hd5e0ee1920ce73e8ISq
   9:     0x7f2effaa062e - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::consume_expr::hb81a1dd7908ebc92pKq
  10:     0x7f2effaf04ee - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_expr::hd5e0ee1920ce73e8ISq
  11:     0x7f2effaa062e - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::consume_expr::hb81a1dd7908ebc92pKq
  12:     0x7f2effaa1d4a - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_fn::h6a2cdb0716cadae2IEq
  13:     0x7f2f00b8c218 - check::upvar::AdjustBorrowKind<'a, 'tcx>.Visitor<'v>::visit_fn::hc504883e0b3cd6c75ak
  14:     0x7f2f00b8be71 - visit::walk_expr::h13583637414739678307
  15:     0x7f2f00b8b9ba - visit::walk_expr::h13583637414739678307
  16:     0x7f2f00bd2a5b - check::check_bare_fn::h3411c093c6d150c8Krp
  17:     0x7f2f00bd0735 - check::check_item_body::hcb5b1c88db3753adCSp
  18:     0x7f2f00c8c292 - check_crate::h59388462a455f882BAE
  19:     0x7f2f0205952e - driver::phase_3_run_analysis_passes::closure.20568
  20:     0x7f2f0203a093 - middle::ty::ctxt<'tcx>::create_and_enter::h17125065020165046703
  21:     0x7f2f020353dd - driver::phase_3_run_analysis_passes::h10216181492887698053
  22:     0x7f2f020185f6 - driver::compile_input::h49d27ccc543a1a4dTba
  23:     0x7f2f02181edb - run_compiler::h700a20be786a24cf0bc
  24:     0x7f2f0217f7a7 - boxed::F.FnBox<A>::call_box::h11300806918882369423
  25:     0x7f2f0217f214 - rt::unwind::try::try_fn::h584903217560229256
  26:     0x7f2f01b0aeb8 - __rust_try
  27:     0x7f2f01af7862 - rt::unwind::try::inner_try::h39e46f240c41c556XDw
  28:     0x7f2f0217f3a8 - boxed::F.FnBox<A>::call_box::h3984513613283807944
  29:     0x7f2f01b0a303 - sys::thread::Thread::new::thread_start::h8f5cafe3c6de8ce2KNv
  30:     0x7f2efc3386c9 - start_thread
  31:     0x7f2f0178b99c - __clone
  32:                0x0 - <unknown>

Looks similar to #21305.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions