Skip to content

ICE using unboxed closure sugar for FnOnce #17655

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

Closed
pythonesque opened this issue Sep 30, 2014 · 5 comments
Closed

ICE using unboxed closure sugar for FnOnce #17655

pythonesque opened this issue Sep 30, 2014 · 5 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@pythonesque
Copy link
Contributor

Sorry if this is a duplicate, I couldn't find anything.

#![feature(unboxed_closures,overloaded_calls)]

fn main() {
  let foo = 0i8;
  let bar = |:|{ foo };
}

$ RUST_BACKTRACE=1 rustc foo.rs
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 'no entry found for key', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libstd/collections/hashmap/map.rs:1093

stack backtrace:
   1:     0x7f93d1980740 - rt::backtrace::imp::write::ha917ced5a810f66cUVq
   2:     0x7f93d19838d0 - failure::on_fail::h35f292864ffd1035mhr
   3:     0x7f93d21399e0 - unwind::begin_unwind_inner::h7b2733ff05e8f899SUd
   4:     0x7f93d25123c0 - unwind::begin_unwind::h3837541141404774985
   5:     0x7f93d26ed130 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_captures::closure.113283
   6:     0x7f93d26ed010 - middle::ty::with_freevars::h15643820832341047709
   7:     0x7f93d2701150 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h17509852025542073980
   8:     0x7f93d2700e30 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_block::h7871336635011900049
   9:     0x7f93d26fb0e0 - middle::borrowck::gather_loans::gather_loans_in_fn::h4d158f6362a75ab3P3h
  10:     0x7f93d2721420 - middle::borrowck::build_borrowck_dataflow_data::hf1c03f8dbedd6896XQj
  11:     0x7f93d271e8d0 - middle::borrowck::borrowck_fn::h4dd4dc3f33cb9c337Nj
  12:     0x7f93d27206c0 - visit::walk_item::h977840171384247700
  13:     0x7f93d271f080 - middle::borrowck::check_crate::hc8b4d432f8d78572VGj
  14:     0x7f93d252fc50 - util::common::time::h5222882638945901854
  15:     0x7f93d2d65790 - driver::driver::phase_3_run_analysis_passes::h4c733c82d969baafkPw
  16:     0x7f93d2d60fa0 - driver::driver::compile_input::hd245ec58bbc2ac2b9vw
  17:     0x7f93d2de2da0 - driver::run_compiler::h88fa61952d453b8cdmA
  18:     0x7f93d2de2c80 - driver::main_args::closure.146353
  19:     0x7f93d2548be0 - task::TaskBuilder<S>::try_future::closure.101568
  20:     0x7f93d25489d0 - task::TaskBuilder<S>::spawn_internal::closure.101539
  21:     0x7f93d36f1fa0 - task::spawn_opts::closure.8494
  22:     0x7f93d218eb20 - rust_try_inner
  23:     0x7f93d218eb10 - rust_try
  24:     0x7f93d2136b70 - unwind::try::hef24d636384aaae6AJd
  25:     0x7f93d2136a00 - task::Task::run::hbcbabe3609aa7293UYc
  26:     0x7f93d36f1d10 - task::spawn_opts::closure.8434
  27:     0x7f93d2138a80 - thread::thread_start::h86947667e5e1368fpjd
  28:     0x7f93d144a250 - start_thread
  29:     0x7f93d1e0f3b9 - clone
  30:                0x0 - <unknown>
@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 1, 2014
@bkoropoff
Copy link
Contributor

Taking a look

@bkoropoff
Copy link
Contributor

It appears that walk_captures is expecting to find the free var in the upvar_borrow_map, but regionck did not populate it with anything.

@bkoropoff
Copy link
Contributor

I might have a fix for this, stand by

@bkoropoff
Copy link
Contributor

Well, I fixed the ICE, but upon further inspection it seems that by-ref variable capture in unboxed closures isn't completely baked. I have some patches that seem to get things working in regionck/borrowck, but trans still needs work. I'm not sure if I should continue on this path since @pcwalton may have other plans here.

bkoropoff added a commit to bkoropoff/rust that referenced this issue Oct 3, 2014
…losures

This prevents a later ICE in borrowck.

Closes issue rust-lang#17655
bkoropoff added a commit to bkoropoff/rust that referenced this issue Oct 3, 2014
This test works as a regression test for issue rust-lang#17655.  It also
exercises mutation of by-ref upvars.
bors added a commit that referenced this issue Oct 4, 2014
This began as an attempt to fix an ICE in borrowck (issue #17655), but the rabbit hole went pretty deep.  I ended up plumbing support for capture-by-reference unboxed closures all the way into trans.

Closes issue #17655.
@bkoropoff
Copy link
Contributor

For some reason github did not mark the PR as merged, but this bug is fixed and can be closed.

lnicola pushed a commit to lnicola/rust that referenced this issue Jul 28, 2024
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 1, 2024
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

3 participants