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 internal error: subtype error #17033

Closed
GuillaumeGomez opened this issue Sep 5, 2014 · 7 comments · Fixed by #17130
Closed

compiler internal error: subtype error #17033

GuillaumeGomez opened this issue Sep 5, 2014 · 7 comments · Fixed by #17130
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@GuillaumeGomez
Copy link
Member

Hey,

Here's the bug description :

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 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/ast_util.rs:784

stack backtrace:
   1:     0x7f0af2d49120 - rt::backtrace::imp::write::h3c0523c13636656fOLq
   2:     0x7f0af2d4c310 - failure::on_fail::h9a355b0a53be785cw7q
   3:     0x7f0af3534740 - unwind::begin_unwind_inner::h0ab5484e74ee0101rje
   4:     0x7f0aeef8d310 - unwind::begin_unwind::h13307728250319235624
   5:     0x7f0aeef8d260 - diagnostic::SpanHandler::span_bug::hd3a5390ca4771f82c7E
   6:     0x7f0af3ad09c0 - driver::session::Session::span_bug::h0a5e146c6cf2b5d6z5C
   7:     0x7f0af3ec0d90 - middle::typeck::check::method::LookupContext<'a>::bug::h9a33b4d07f69923cE7T
   8:     0x7f0af3ec0e10 - middle::typeck::check::method::LookupContext<'a>::consider_candidates::hd71b17fb2347b67bAhT
   9:     0x7f0af3ebeb70 - middle::typeck::check::method::LookupContext<'a>::search_for_method::h120681b24b4af1c9ZbT
  10:     0x7f0af3eb86f0 - middle::typeck::check::method::LookupContext<'a>::search_for_autoderefd_method::hd5035f1a55ee2f7b0GS
  11:     0x7f0af3eb75e0 - middle::typeck::check::method::LookupContext<'a>::search_step::hd82b82931d4ce8fbDUR
  12:     0x7f0af3eb50c0 - middle::typeck::check::method::LookupContext<'a>::search::h493a1bb3adffef68hTR
  13:     0x7f0af3eb5b40 - middle::typeck::check::method::lookup_in_trait::h07cf77d528545225dIR
  14:     0x7f0af3f14600 - middle::typeck::check::try_overloaded_call::he76080159aee37b6C3W
  15:     0x7f0af3f1a3a0 - middle::typeck::check::check_expr_with_unifier::hf0af3bf6d346d9a50UX
  16:     0x7f0af3f234d0 - middle::typeck::check::check_expr_with_unifier::check_binop::hdbfd9cf45432c1f0dcY
  17:     0x7f0af3f1a3a0 - middle::typeck::check::check_expr_with_unifier::hf0af3bf6d346d9a50UX
  18:     0x7f0af3ed8e90 - middle::typeck::check::check_block_with_expected::ha3382383e0174a72c2Z
  19:     0x7f0af3ed3c90 - middle::typeck::check::check_fn::hd8d96b66c3c25771wDU
  20:     0x7f0af3ed3a60 - middle::typeck::check::check_bare_fn::h2aaf5a27582ba014hsU
  21:     0x7f0af3ecc4c0 - middle::typeck::check::check_item::h0d35a108b1e2219207U
  22:     0x7f0af3ece420 - visit::walk_item::h4994048128054535781
  23:     0x7f0af3ece420 - visit::walk_item::h4994048128054535781
  24:     0x7f0af3ed3790 - middle::typeck::check::check_item_types::hc4d314b34aa4fa7fgrU
  25:     0x7f0af3915260 - util::common::time::h14172350515681977473
  26:     0x7f0af410de80 - middle::typeck::check_crate::hbe9ce24801a7cbd7vSm
  27:     0x7f0af41cf500 - driver::driver::phase_3_run_analysis_passes::hc7abcc76bf622eafiyB
  28:     0x7f0af41cabf0 - driver::driver::compile_input::ha48623fcead7bd7e5jB
  29:     0x7f0af425e890 - driver::run_compiler::h0b258b9c360b66ddjRE
  30:     0x7f0af425e7a0 - driver::main_args::closure.141085
  31:     0x7f0af4272dc0 - task::TaskBuilder<S>::try_future::closure.142270
  32:     0x7f0af4272bc0 - task::TaskBuilder<S>::spawn_internal::closure.142247
  33:     0x7f0af4cdd0b0 - task::spawn_opts::closure.8370
  34:     0x7f0af358d490 - rust_try_inner
  35:     0x7f0af358d480 - rust_try
  36:     0x7f0af3531cf0 - unwind::try::hea1640d217ab7457H7d
  37:     0x7f0af3531a90 - task::Task::run::hb52aad40b24ebf23Ndd
  38:     0x7f0af4cdce10 - task::spawn_opts::closure.8316
  39:     0x7f0af3533930 - thread::thread_start::h741158bbfb282555MCd
  40:     0x7f0af27dd0c0 - start_thread
  41:     0x7f0af31faf89 - __clone
  42:                0x0 - <unknown>

And here is my rust compiler version :

> rustc -v
rustc 0.12.0-pre-nightly (5419b2ca2 2014-08-29 22:16:20 +0000)

You can redo this bug with this project on the bug branch.

@mdinger
Copy link
Contributor

mdinger commented Sep 6, 2014

I shrunk this to a much smaller test case.

rgsl.rs:

use std::intrinsics::sinf64;

pub type function<T> = fn(x: f64, p: &mut T) -> f64;

struct InternParam<'r, T:'r> {
    func: ::function<T>,
    param: &'r mut T,
    p2: f64
}

struct fn_fourier_params<'r, T:'r> {
    omega: f64,
    function: &'r mut ::function<T>,
    arg: &'r mut T
}

unsafe fn fn_sin<T>(x: f64, p: &mut fn_fourier_params<T>) -> f64 {
    let f = p.function;
    let w = p.omega;
    let wx = w * x;
    let sinwx = sinf64(wx);

    f(x, p.arg) * sinwx
}

Build output:

$ cargo build
   Compiling rust-GSL v0.4.9 (file:///home/mdinger/Programs/gsl/rust-GSL)
src/rgsl.rs:23:5: 23:16 error: internal compiler error: &mut fn(f64, &mut T) -> f64 was a subtype of &mut fn(<generic #15>, <generic #16>) -> <generic #14> but now is not?
src/rgsl.rs:23     f(x, p.arg) * sinwx
                   ^~~~~~~~~~~
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 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/ast_util.rs:776


Could not compile `rust-GSL`.

To learn more, run the command again with --verbose.

[EDIT]
I've edited this to be up to date with my repository.
Removed the branch after he got minimum testcase.

@GuillaumeGomez
Copy link
Member Author

It's a lot better like that, thanks !

@ghost
Copy link

ghost commented Sep 6, 2014

Minimal:

fn f<'r>(p: &'r mut fn(p: &mut ())) {
    p(())
}

fn main() {}

@sfackler sfackler added the I-ICE label Sep 6, 2014
@nikomatsakis
Copy link
Contributor

cc me

@cakey
Copy link

cakey commented Oct 21, 2014

Hey,
Wasn't sure where else to put this, but I came across a bug that seems similar:

Code:

use std::iter::AdditiveIterator;

fn adder(args: [f64]) -> f64 {
    args.sum()
}

fn main() {

}

Report:

/Users/b.shaw/Projects/rust/bug.rs:4:5: 4:15 error: internal compiler error: &mut [f64] was a subtype of &mut <generic #38> but now is not?
/Users/b.shaw/Projects/rust/bug.rs:4     args.sum()
                                             ^~~~~~~~~~
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 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:116

(On Mac 10.10 nightly installer)

@nikomatsakis
Copy link
Contributor

@cakey I don't see that error when checking with a local build (at least not anymore). You may want to upgrade. Note also that the code is illegal. A working version looks something like this (maybe there's a nicer way to do it, not sure):

use std::iter::AdditiveIterator;

fn adder(args: &[f64]) -> f64 {
    args.iter().map(|x| *x).sum()
}

fn main() {

}

UPDATE: fixed code example

@cakey
Copy link

cakey commented Oct 30, 2014

@nikomatsakis Seems to be fixed! Nice.
Yeah I know the code was bad, but figured it still shouldn't crash the compiler!

lnicola pushed a commit to lnicola/rust that referenced this issue Apr 20, 2024
lnicola pushed a commit to lnicola/rust that referenced this issue Apr 20, 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

Successfully merging a pull request may close this issue.

5 participants