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 Cannot relate bound region #25750

Closed
Kintaro opened this issue May 24, 2015 · 5 comments
Closed

ICE Cannot relate bound region #25750

Kintaro opened this issue May 24, 2015 · 5 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Kintaro
Copy link
Contributor

Kintaro commented May 24, 2015

I hit an internal compiler error with this weeks build. It occurs when I try to build https://github.com/Kintaro/wtftw/tree/1d8040fddfedfd3b111bb4d5a8466fcb8120e339

Error output and rustc version are below.

rustc 1.2.0-dev (0fc0476 2015-05-24) (built 2015-05-24)

Unfortunately, #25652 did not fix the issue. It's caused by this part here https://github.com/Kintaro/wtftw/blob/1d8040fddfedfd3b111bb4d5a8466fcb8120e339/core/src/config.rs#L110

core/src/config.rs:116:13: 116:28 error: internal compiler error: cannot relate bound region: ReScope(Remainder(BlockRemainder { block: 150, first_statement_index: 3 })) <= ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(0))
core/src/config.rs:116         let internal_config = 
                                   ^~~~~~~~~~~~~~~
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
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rootnode/programs/src/rust/src/libsyntax/diagnostic.rs:176
@Kintaro Kintaro changed the title Cannot relate bound region (internal compiler error) ICE Cannot relate bound region May 24, 2015
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 25, 2015
@Kintaro
Copy link
Contributor Author

Kintaro commented May 28, 2015

Forgot to add the backtrace:

stack backtrace:
   1:     0x7f947750c183 - sys::backtrace::write::h615fdb4d732e4a93r6r
   2:     0x7f9477514049 - panicking::on_panic::h9a7e45e333684aa03Lw
   3:     0x7f94774d4e3a - rt::unwind::begin_unwind_inner::h995a60547c3f562eNrw
   4:     0x7f947482cbbd - rt::unwind::begin_unwind::h17375738179658217201
   5:     0x7f947482cb52 - diagnostic::SpanHandler::span_bug::h8482da51d213c57buqC
   6:     0x7f9475553cda - middle::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::hb699f35a3cfa39c6UPv
   7:     0x7f947556cd1f - middle::infer::mk_subr::h93c112efb784e579G5y
   8:     0x7f9476c3ba0f - check::regionck::type_must_outlive::h68e52339b49b7368Tte
   9:     0x7f9476c39baa - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h80326f55a8cc05afZDa
  10:     0x7f9476c39d5c - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h80326f55a8cc05afZDa
  11:     0x7f9476c39d5c - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h80326f55a8cc05afZDa
  12:     0x7f9476c39f13 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h80326f55a8cc05afZDa
  13:     0x7f9476c39d5c - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h80326f55a8cc05afZDa
  14:     0x7f9476c39d5c - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h80326f55a8cc05afZDa
  15:     0x7f9476c39d5c - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h80326f55a8cc05afZDa
  16:     0x7f9476c38738 - check::dropck::check_safety_of_destructor_if_necessary::h6d78b805219652e19xa
  17:     0x7f9476c7033d - check::regionck::check_safety_of_rvalue_destructor_if_necessary::ha65a719fd22d79bdjPd
  18:     0x7f9476c69b81 - check::regionck::visit_expr::h15cc0f7c6e849ab0fad
  19:     0x7f9476c67bb1 - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h461f8d4e496574beHMc
  20:     0x7f9476c67090 - check::regionck::regionck_fn::hf51a587df53131353Ec
  21:     0x7f9476ce2dc8 - check::check_bare_fn::h56477091183bbe08gOn
  22:     0x7f9476ceed5c - check::check_method_body::h11b8e4f5d8c75e9crro
  23:     0x7f9476ce0913 - check::check_item_body::hc9468be7e10fb9049eo
  24:     0x7f9476ce0f02 - visit::walk_item::h10209465936042145449
  25:     0x7f9476ce278f - check::check_item_types::h22d39728d2ed74ffNLn
  26:     0x7f9476d9f026 - check_crate::h0c48e68f075d51d7g7C
  27:     0x7f9477a68d9f - driver::phase_3_run_analysis_passes::h34501209e3394a5cGGa
  28:     0x7f9477a4bf3c - driver::compile_input::h69c18a97a3bef03fQba
  29:     0x7f9477b01b31 - run_compiler::h737927eeae91ebd5n6b
  30:     0x7f9477aff382 - boxed::F.FnBox<A>::call_box::h1962494538046773488
  31:     0x7f9477afeb89 - rt::unwind::try::try_fn::h2931293082837064848
  32:     0x7f9477597138 - rust_try_inner
  33:     0x7f9477597125 - rust_try
  34:     0x7f94774ffc37 - rt::unwind::try::inner_try::h80226bb4deb2a8ebGnw
  35:     0x7f9477afeda9 - boxed::F.FnBox<A>::call_box::h2098047553192396313
  36:     0x7f9477512d01 - sys::thread::Thread::new::thread_start::h97730f674d383241Sxv
  37:     0x7f9471f720a3 - start_thread
  38:     0x7f947715c04c - clone
  39:                0x0 - <unknown>

@Kintaro
Copy link
Contributor Author

Kintaro commented May 31, 2015

Ok, I was able to produce a small example that causes it:

use std::collections::BTreeMap;

pub type ManageHook = Box<Fn(Workspaces, &WindowSystem, Window) -> Workspaces>;
pub type LogHook = Box<FnMut(WindowManager, &WindowSystem)>;

pub trait WindowSystem {}
pub struct WindowManager;
pub struct Workspaces;
pub type Window = u64;

pub struct GeneralConfig;

pub struct InternalConfig {
    pub manage_hook: ManageHook,
    pub loghook: Option<LogHook>,
}

impl InternalConfig {
    pub fn new(manage_hook: ManageHook) -> InternalConfig {
        InternalConfig {
            manage_hook: manage_hook,
            loghook: None,
        }
    }
}

fn main() {
}

http://is.gd/UnSdRQ

@betawaffle
Copy link

Reduced even further:

pub type BoxedFn = Box<Fn(&Trait)>;

pub trait Trait {}

pub fn new() -> Option<(BoxedFn, BoxedFn)> {
    None
}
src/lib.rs:6:5: 6:9 error: internal compiler error: cannot relate bound region: ReScope(DestructionScope(18)) <= ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(0))
src/lib.rs:6     None
                 ^~~~
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>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:176

stack backtrace:
   1:        0x1089077b5 - sys::backtrace::write::h1561c90743d5c179M9r
   2:        0x1089103f0 - panicking::on_panic::h8a5d860d5a124e0a2uw
   3:        0x1088ca948 - rt::unwind::begin_unwind_inner::hb33d13fc310a98afkdw
   4:        0x10807987e - rt::unwind::begin_unwind::h9699143272701214950
   5:        0x10807980a - diagnostic::SpanHandler::span_bug::h4a339f86ecbb72a1uqC
   6:        0x105ae38b4 - middle::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h30bc770a31311672yRv
   7:        0x105afdf1b - middle::infer::mk_subr::h9a5b48e4c252ec91k7y
   8:        0x105606b2a - check::regionck::type_must_outlive::h8d529e58bca1ccb0Tte
   9:        0x105604ac5 - check::dropck::iterate_over_potentially_unsafe_regions_in_type::ha9d169bb6b0bbca3ZDa
  10:        0x105604e1e - check::dropck::iterate_over_potentially_unsafe_regions_in_type::ha9d169bb6b0bbca3ZDa
  11:        0x105603701 - check::dropck::check_safety_of_destructor_if_necessary::h3060ac778c5992289xa
  12:        0x10563d93e - check::regionck::check_safety_of_rvalue_destructor_if_necessary::hcf8a4293ce5c60bfjPd
  13:        0x105636eb3 - check::regionck::visit_expr::h79aea6e9fda81e97fad
  14:        0x105634cde - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h09869d1c412f3624HMc
  15:        0x1056340a3 - check::regionck::regionck_fn::hfdd6d8acf07f17563Ec
  16:        0x1056b133d - check::check_bare_fn::hc9c7a17ca1e4729egOn
  17:        0x1056aef37 - check::check_item_body::h103df4808fcb6e559eo
  18:        0x1056b0c73 - check::check_item_types::h7c6eaf781d12ace8NLn
  19:        0x105770f10 - check_crate::h8fe4e687b73e5015g7C
  20:        0x104f9b68f - driver::phase_3_run_analysis_passes::hef736cb124de6565GGa
  21:        0x104f7f403 - driver::compile_input::h7a3800e0d9c4bbe3Qba
  22:        0x105039e04 - run_compiler::h3864143d185b8964n6b
  23:        0x10503756a - boxed::F.FnBox<A>::call_box::h4644100161726726905
  24:        0x105036c87 - rt::unwind::try::try_fn::h5144344175023612934
  25:        0x108998bf8 - rust_try_inner
  26:        0x108998be5 - rust_try
  27:        0x1088fa315 - rt::unwind::try::inner_try::hbe91c83f4d153e36d9v
  28:        0x105036ee2 - boxed::F.FnBox<A>::call_box::h10871128639736673174
  29:        0x10890eeed - sys::thread::Thread::new::thread_start::h89e4611b0ac51fcbMxv
  30:     0x7fff8852a267 - _pthread_body
  31:     0x7fff8852a1e4 - _pthread_start

@betawaffle
Copy link

And, once again:

# Fails
fn fail() -> Option<(Box<Fn(&Sized)>, Box<Fn(&Sized)>)> {
    None
}

# Works
fn work<'a>() -> Option<(Box<Fn(&'a Sized)>, Box<Fn(&'a Sized)>)> {
    None
}

@marcmmiller
Copy link

FWIW, I ran into this also, but don't have time to whittle this down to a small repro.

$ rustc --version
rustc 1.0.0 (a59de37 2015-05-13) (built 2015-05-14)

main.rs:532:37: 532:41 error: internal compiler error: cannot relate bound region: ReScope(DestructionScope(3503)) <= ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(0))
main.rs:532 Builtin { name: name, func: func }
^~~~
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
note: run with RUST_BACKTRACE=1 for a backtrace
thread 'rustc' panicked at 'Box', /Users/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:149

stack backtrace:
1: 0x10eb59e7f - sys::backtrace::write::h7807ec07859fb503t1r
2: 0x10eb624b2 - panicking::on_panic::ha0ed2b9b562a7f9ctZv
3: 0x10eb1ee35 - rt::unwind::begin_unwind_inner::hbfb8d99cb52be7a1cHv
4: 0x10e30743e - rt::unwind::begin_unwind::h14482673826369992638
5: 0x10e3073ca - diagnostic::SpanHandler::span_bug::ha80d5103c6dc346fEqB
6: 0x10c1ccc2b - middle::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h424c309cfde0bc8dtiv
7: 0x10c1e8a90 - middle::infer::mk_subr::h4f040a8108e68139XWy
8: 0x10b7c14ed - check::regionck::type_must_outlive::hb12e90041719991fQBe
9: 0x10b7bf0bd - check::dropck::iterate_over_potentially_unsafe_regions_in_type::h5b033045bf4886b5CDa
10: 0x10b7bde51 - check::dropck::check_safety_of_destructor_if_necessary::h7327a46d7b6457bcMxa
11: 0x10b7f26de - check::regionck::check_safety_of_rvalue_destructor_if_necessary::hdb7e84c483faff56gXd
12: 0x10b7ebd04 - check::regionck::visit_expr::hcfb3f0e73f4f1ee5Yhd
13: 0x10b7f310e - visit::walk_expr::h8074881990300037598
14: 0x10b7ec8e9 - check::regionck::visit_expr::hcfb3f0e73f4f1ee5Yhd
15: 0x10b7e9d8e - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h6ad291664793346cpUc
16: 0x10b866cc7 - check::check_bare_fn::h87d6505bed3e4c61twn
17: 0x10b86f887 - check::check_method_body::h1802c6d6e15675a6Y7n
18: 0x10b8648cb - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h97ae569543a98538wtn
19: 0x10b92ef4a - check_crate::closure.38028
20: 0x10b92a357 - check_crate::h722813c75c795e06XcC
21: 0x10b6945f4 - driver::phase_3_run_analysis_passes::h3394cefeecbff846nGa
22: 0x10b675ffc - driver::compile_input::hf0607b3d1fd498bcQba
23: 0x10b73e5a3 - run_compiler::he7a5311c755081d7z4b
24: 0x10b73c0ca - boxed::F.FnBox::call_box::h5234503372052129763
25: 0x10b73b567 - rt::unwind::try::try_fn::h4031265711883657142
26: 0x10ebe3508 - rust_try_inner
27: 0x10ebe34f5 - rust_try
28: 0x10b73b840 - boxed::F.FnBox::call_box::h1044299548107784679
29: 0x10eb60ffd - sys::thread::create::thread_start::ha3be9b31a8775143L4u
30: 0x7fff99511898 - _pthread_body
31: 0x7fff99511729 - _pthread_start

@ghost ghost mentioned this issue Jun 16, 2015
keiichiw added a commit to keiichiw/rust that referenced this issue Jul 20, 2015
Don't add a type to breadcrumbs vector when it is reference, pointer, or bare functions.
Fixes rust-lang#25750
pnkfelix added a commit to pnkfelix/rust that referenced this issue Jul 23, 2015
In particular, when we traverse a type like:

  `(for <'r> Fn(&'r u8), for <'r> Fn(&'r u8))`

we should not add the first type `Fn(&'r u8)` to the bread-crumbs set,
because that type ends up being structurally equivalent to the
*second* `Fn(&'r u8)` type, even though they each should be considered
distinct since they occur under distinct `for <'r>` binders.

Fix rust-lang#25750.
pnkfelix added a commit to pnkfelix/rust that referenced this issue Jul 23, 2015
In particular, when we traverse a type like:

  `(for <'r> Fn(&'r u8), for <'r> Fn(&'r u8))`

we should not add the first type `Fn(&'r u8)` to the bread-crumbs set,
because that type ends up being structurally equivalent to the
*second* `Fn(&'r u8)` type, even though they each should be considered
distinct since they occur under distinct `for <'r>` binders.

Fix rust-lang#25750.
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