Skip to content

compiler bug for a simple test file #6128

Closed
@c-cube

Description

@c-cube

I got this stacktrace while running "rust test" on a file. The end of the trace contains a failure message. I have an archlinux 64bits, with rust-0.6-3 (compiled on april 6th, 2013). The code is at the bottom of the page.

RUST_LOG=rustc=1,::rt::backtrace !!                                                                                                   rust-graph [v/]
RUST_LOG=rustc=1,::rt::backtrace make
rust test src/graph.rs
src/graph.rs:24:8: 24:12 warning: unused variable: `g2`
src/graph.rs:24     let g2 : ~Graph<int,int> = g as ~Graph<int,int>;
                        ^~~~
rust: task failed at 'index out of bounds: the len is 1 but the index is 1', /build/src/rust-0.6/src/librustc/middle/ty.rs:1369
/usr/lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4b)[0x7f381ec5b64b]
/usr/lib/librustrt.so(+0x2a189)[0x7f381ec6c189]
/usr/lib/librustrt.so(upcall_fail+0x198)[0x7f381ec5d3a8]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x1055db)[0x7f382078f5db]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x4d1be)[0x7f38206d71be]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN8unstable4lang17fail_bounds_check16_6fb13a2fe60974b3_06E+0x22f)[0x7f38206e051f]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty9subst_tps15_fee8f4df464e9d3_06E+0x208)[0x7f381efc0e28]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x37aa8d)[0x7f381f217a8d]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x11a78f)[0x7f381efb778f]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x3776fa)[0x7f381f2146fa]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty14fold_sty_to_ty16_838dc9297a1a6e73_06E+0x58)[0x7f381f214028]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty9subst_tps15_fee8f4df464e9d3_06E+0x17d)[0x7f381efc0d9d]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x37aa8d)[0x7f381f217a8d]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x377aa6)[0x7f381f214aa6]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty14fold_sty_to_ty16_838dc9297a1a6e73_06E+0x58)[0x7f381f214028]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty9subst_tps15_fee8f4df464e9d3_06E+0x17d)[0x7f381efc0d9d]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x37aa8d)[0x7f381f217a8d]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty8fold_sig16_c5fce010a53c19b3_06E+0xb3)[0x7f381f215383]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x37746a)[0x7f381f21446a]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty14fold_sty_to_ty16_838dc9297a1a6e73_06E+0x58)[0x7f381f214028]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty9subst_tps15_fee8f4df464e9d3_06E+0x17d)[0x7f381efc0d9d]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x37aa8d)[0x7f381f217a8d]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty8fold_sig16_c5fce010a53c19b3_06E+0xb3)[0x7f381f215383]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x3773bc)[0x7f381f2143bc]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty14fold_sty_to_ty16_838dc9297a1a6e73_06E+0x58)[0x7f381f214028]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle2ty9subst_tps15_fee8f4df464e9d3_06E+0x17d)[0x7f381efc0d9d]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x2f148b)[0x7f381f18e48b]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x2f121f)[0x7f381f18e21f]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4meth16make_impl_vtable16_8f771b61f2df1a53_06E+0x2fa)[0x7f381f18d22a]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4meth10get_vtable17_dcd24c16d2c3ccf63_06E+0x304)[0x7f381f18cce4]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4meth16trans_trait_cast16_9c795ee9255f1203_06E+0x8b8)[0x7f381f0a8008]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x1fea62)[0x7f381f09ba62]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4expr10trans_into16_54d763e594233573_06E+0xe97)[0x7f381effc727]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base10init_local15_3c07168daf987d3_06E+0x65f)[0x7f381f0ff3ef]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x8b8c14)[0x7f381f755c14]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x2646db)[0x7f381f1016db]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base10trans_stmt17_2c2aa18584fe5be63_06E+0x5ae)[0x7f381effb45e]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x15d49c)[0x7f381effa49c]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans11controlflow11trans_block16_a4e9a67bdd72ccb3_06E+0x19e)[0x7f381eff8c0e]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base13trans_closure17_85d646a672f846683_06E+0x50e)[0x7f381f10a7ae]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base8trans_fn17_fe1e7f81b93e452d3_06E+0x3b9)[0x7f381efb2489]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base10trans_item16_ed7df62f5f126563_06E+0xd52)[0x7f381efaa0e2]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base9trans_mod17_33f95ffa6ea6f19d3_06E+0xa3)[0x7f381f111323]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base11trans_crate15_aa5d2b86af98143_06E+0x13c4)[0x7f381f130fd4]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x87a380)[0x7f381f717380]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_rest17_b2b258b84b35f3533_06E+0x331e)[0x7f381f71438e]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x8b8c14)[0x7f381f755c14]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_upto17_12335154b455986e3_06E+0x108)[0x7f381f717598]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x8b8c14)[0x7f381f755c14]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver13compile_input15_bb29edf7a232863_06E+0xca)[0x7f381f7179da]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN12run_compiler17_64d52739a36d169c3_06E+0x20aa)[0x7f381f7470aa]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x8b66e1)[0x7f381f7536e1]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x8b2f0c)[0x7f381f74ff0c]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x8b8c14)[0x7f381f755c14]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(+0xce08e)[0x7f382075808e]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x14dcb4)[0x7f38207d7cb4]
/usr/lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f381ec5be64]
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /build/src/rust-0.6/src/librustc/rustc.rc:357
/usr/lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4b)[0x7f381ec5b64b]
/usr/lib/librustrt.so(+0x2a189)[0x7f381ec6c189]
/usr/lib/librustrt.so(upcall_fail+0x198)[0x7f381ec5d3a8]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x1055db)[0x7f382078f5db]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x105582)[0x7f382078f582]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7f38206d7651]
/usr/lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x14dcb4)[0x7f38207d7cb4]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN7monitor17_78935df9ff9e1afa3_06E+0x1577)[0x7f381f7496d7]
/usr/lib/librustc-c84825241471686d-0.6.so(+0x8b8c14)[0x7f381f755c14]
/usr/lib/librustc-c84825241471686d-0.6.so(_ZN4main15_c4de63b748e03d3_06E+0x7e)[0x7f381f75582e]
/usr/lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f381ec5be64]
rust: domain main @0x23b03c0 root task failed

code:

extern mod core;                                                                                    

use core::hashmap::linear::LinearMap;                                                               
use core::hashmap::linear::linear_map_with_capacity;                                                

// #[crate_type = "lib"];                                                                           

trait Graph<Node, Edge> {                                                                           
    fn children(&self, Node, &fn(&(Edge, Node)) ⟶  bool);   // iterate on outgoing edges            
}                                                                                                    

impl<E> Graph<int,E> for LinearMap<int, ~[(E,int)]> {                                               
    fn children(&self, n:int, f : &fn(&(E,int)) ⟶  bool) {                                          
        match self.find(&n) {                                                                           
            None ⟹  (),                                                                              
            Some(list) ⟹  list.each(f)                                                               
        };                                                                                              
    }                                                                                               
}                                                                                                    

#[test]                                                                                             
fn test_1() {                                                                                       
    let g : ~LinearMap<int, ~[(int,int)]> = ~linear_map_with_capacity(15);                          
    let g2 : ~Graph<int,int> = g as ~Graph<int,int>;                                                
}                           

Activity

Thiez

Thiez commented on Apr 30, 2013

@Thiez
Contributor

It seems you are using an old version of rust (based on your use of LinearMap, which has since been renamed to HashMap). Does this crash also happen on incoming?

c-cube

c-cube commented on May 1, 2013

@c-cube
Author

Looks like my computer is not powerful enough to build rust from git+https://github.com/mozilla/rust.git ...

Tristramg

Tristramg commented on May 1, 2013

@Tristramg

I tested with master (bfccfdc)

And I get the same problem https://gist.github.com/Tristramg/5494814

catamorphism

catamorphism commented on Jul 15, 2013

@catamorphism
Contributor

Simpler test case:

use std::hashmap::HashMap;

trait Graph<Node, Edge> {
    fn f(&self, Edge);

}

impl<E> Graph<int, E> for HashMap<int, int> {
    fn f(&self, _e: E) {
        fail!();
    }
}

fn main() {
    let g : ~HashMap<int, int> = ~HashMap::new();
    let _g2 : ~Graph<int,int> = g as ~Graph<int,int>;
}

Reproduced with 8d0feb5 . Nominating for milestone 5, production-ready.

graydon

graydon commented on Aug 22, 2013

@graydon
Contributor

accepted for production-ready milestone

sanxiyn

sanxiyn commented on Oct 8, 2013

@sanxiyn
Member

I don't get ICE anymore.

alexcrichton

alexcrichton commented on Oct 8, 2013

@alexcrichton
Member

Hurrah! flagging as needstest, but this probably just needs the test case un-xfail'd

alexcrichton

alexcrichton commented on Oct 11, 2013

@alexcrichton
Member

The test was actually already checked in and was un-xfail'd in 364beaa

added a commit that references this issue on Oct 9, 2020

Auto merge of rust-lang#6128 - dtolnay:rc_buffer, r=yaahc

added a commit that references this issue on Feb 1, 2021

Rollup merge of rust-lang#81387 - c410-f3r:tests-tests-tests, r=petro…

69f0364
added a commit that references this issue on Feb 1, 2021

Rollup merge of rust-lang#81387 - c410-f3r:tests-tests-tests, r=petro…

11eb176
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Tristramg@graydon@sanxiyn@alexcrichton@Thiez

        Issue actions

          compiler bug for a simple test file · Issue #6128 · rust-lang/rust