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

ICE: the 1th autoderef failed #28347

Closed
mathstuf opened this issue Sep 11, 2015 · 4 comments
Closed

ICE: the 1th autoderef failed #28347

mathstuf opened this issue Sep 11, 2015 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mathstuf
Copy link
Contributor

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.

@mathstuf
Copy link
Contributor Author

And with latest:

rustc 1.4.0-dev (f6d64219a 2015-09-11)
binary: rustc
commit-hash: f6d64219a4ef8133e5946bf174e5951281b06430
commit-date: 2015-09-11
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: 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>', /home/boeckb/code/depot/group-tools/group-compilers/rust/src/src/libsyntax/diagnostic.rs:176

stack backtrace:
   1:     0x7f60c700f3f9 - sys::backtrace::tracing::imp::write::h8b75e77eba5376947Ds
   2:     0x7f60c7016236 - panicking::on_panic::h5275dab6a5c932f03nx
   3:     0x7f60c6fda43e - rt::unwind::begin_unwind_inner::ha828651abcb14bd2DQw
   4:     0x7f60c18a5ac7 - rt::unwind::begin_unwind::h14112450495354169214
   5:     0x7f60c18a5a86 - diagnostic::SpanHandler::span_bug::h25e95f8c16fb331c6NA
   6:     0x7f60c4ddaf93 - middle::infer::InferCtxt<'a, 'tcx>::adjust_expr_ty::h7088acddd2dd6615qgD
   7:     0x7f60c4d4c91b - middle::infer::InferCtxt<'a, 'tcx>::expr_ty_adjusted::h77cfa3384bb70a47dCD
   8:     0x7f60c4d2230d - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_expr::hba228794d7686b2e9Rq
   9:     0x7f60c4cd59de - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::consume_expr::h407b039a1e5fd44dQJq
  10:     0x7f60c4cd59de - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::consume_expr::h407b039a1e5fd44dQJq
  11:     0x7f60c4cd70aa - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_fn::hbb33fd59447aa4099Dq
  12:     0x7f60c5b10bcd - check::upvar::AdjustBorrowKind<'a, 'tcx>.Visitor<'v>::visit_fn::hc93176fa5128af14fbk
  13:     0x7f60c5b10840 - visit::walk_expr::h11868499041215646841
  14:     0x7f60c5b1056e - visit::walk_expr::h11868499041215646841
  15:     0x7f60c5b572c5 - check::check_bare_fn::h06986055badcbbf40yp
  16:     0x7f60c5b54f95 - check::check_item_body::h2301adf3dacd60e8k0p
  17:     0x7f60c5c0de82 - check_crate::h1b9403d493270ff35BE
  18:     0x7f60c75441dd - driver::phase_3_run_analysis_passes::closure.21868
  19:     0x7f60c75268ec - middle::ty::ctxt<'tcx>::create_and_enter::h4064699478710373221
  20:     0x7f60c7521e1e - driver::phase_3_run_analysis_passes::h6837423016930985994
  21:     0x7f60c75017dd - driver::compile_input::h9fd8d131527aff620ba
  22:     0x7f60c766a08b - run_compiler::hd075c291dca55a37qqc
  23:     0x7f60c76679a7 - boxed::F.FnBox<A>::call_box::h1679426590584622772
  24:     0x7f60c7667414 - rt::unwind::try::try_fn::h8745201937627540681
  25:     0x7f60c7015dd8 - __rust_try
  26:     0x7f60c7001fa2 - rt::unwind::try::inner_try::h47ab16ad5f7c2136wMw
  27:     0x7f60c76675a8 - boxed::F.FnBox<A>::call_box::h11492860850382891678
  28:     0x7f60c7015223 - sys::thread::Thread::new::thread_start::hc875ea6af05e7240vWv
  29:     0x7f60c10ea6c9 - start_thread
  30:     0x7f60c6c9499c - __clone
  31:                0x0 - <unknown>

@bluss
Copy link
Member

bluss commented Sep 11, 2015

May be related to #27106

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 11, 2015
@mathstuf
Copy link
Contributor Author

From that issue:

Instead, I have to explicitly dereference and borrow the closure in the loop, with (&mut *closure)(val).

That's what ICE's here.

steveklabnik added a commit to rust-lang/glacier that referenced this issue Nov 28, 2016
@steveklabnik
Copy link
Member

This no longer ICEs as of rustc 1.15.0-nightly (2217bd771 2016-11-25).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants