Skip to content

task 'rustc' failed at 'OwnedSlice: index out of bounds' #14377

Closed
@jbalintbiro

Description

@jbalintbiro

Reduced test case

fn drop_test() {                        
    struct DropCounter<'a> {            
        count: &'a int,                 
    }                                   
    impl <'a> Drop for DropCounter<'a> {
        fn drop(&mut self) { }          
    }                                   
}                                       

Original issue

code that triggered it:

//! probabilistic container

#![crate_id = "skiplist#0"]
#![crate_type = "lib"]

pub struct SkipList<K, V> {
    roots: Vec<Link<K, V>>
}

struct Node<K, V> {
    key: K,
    value: V,
    links: Link<K, V>
}

struct Link<K, V> {
    p: *mut Node<K, V>
}

impl<K, V> Node<K, V> {
}

impl<K, V> SkipList<K, V> {
    pub fn new() -> SkipList<K, V> {
        SkipList { roots: Vec::new() }
    }

    pub fn insert(&self, k: K, v: V) -> bool {
        false
    }

    pub fn find(&self, k: K) -> Option<V> {
        None
    }

    pub fn remove(&self, k: K) -> bool { false }
}

/*impl<K: TotalOrd, V> Map<K, V> for SkipList<K, V> {
    fn find() {}

}*/


#[cfg(test)]
mod tests {
    use super::SkipList;

    #[test]
    fn test_insert_remove() {
        let mut sl = SkipList::new();
        assert!(sl.insert(1, 1));
        assert!(sl.insert(2, 1));
        assert!(sl.insert(3, 1));

        assert!(sl.remove(2));

        assert_eq!(sl.find(1), Some(1));
        assert_eq!(sl.find(2), None);
        assert_eq!(sl.find(4), None);
    }

    #[test]
    fn drop_test() {
        struct DropCounter<'a> {
            count: &'a mut int
        }

        impl<'a> Drop for DropCounter<'a> {
            fn drop(&mut self) {
                *self.count += 1;
            }
        }

        let mut drop_count = 0;
        {
            let mut sl = SkipList::new();
            sl.insert(1, DropCounter {count: &mut drop_count});
            sl.insert(1, DropCounter {count: &mut drop_count});
            sl.insert(2, DropCounter {count: &mut drop_count});
        }
        assert_eq!(drop_count, 3);
    }
}

#[cfg(test)]
mod bench {
    extern crate test;
    use self::test::Bencher;

    #[bench]
    fn bench(b: &mut Bencher) {}

}

trace:
task 'rustc' failed at 'OwnedSlice: index out of bounds', /home/bjb/src/rust/src/libstd/option.rs:167
stack backtrace:
1: 0x7fe1642131b0 - rt::backtrace::imp::write::h96d85ea18992593cPUy::v0.11.0.pre
2: 0x7fe16418ff60 - rt::unwind::begin_unwind_inner::h8ea9fe72e3892daeXuy::v0.11.0.pre
3: 0x7fe164cce9b0 - rt::unwind::begin_unwind::h5064124597624340269::v0.11.0.pre
4: 0x7fe164ebfda0 - middle::ty_fold::super_fold_sty::h1584947460896464705::v0.11.0.pre
5: 0x7fe164d4b640 - middle::subst::SubstFolder<'a>.TypeFolder::fold_ty::ha6ec74b373bc1d03qsR::v0.11.0.pre
6: 0x7fe164dd1bc0 - middle::subst::T.Subst::subst_spanned::h13474638946470633177::v0.11.0.pre
7: 0x7fe164e569d0 - middle::ty::lookup_field_type::heb8a718cf718b4ba9WP::v0.11.0.pre
8: 0x7fe164d34360 - middle::ty::struct_fields::hea2fe481f733123du5P::v0.11.0.pre
9: 0x7fe164e83c60 - middle::ty::type_contents::tc_ty::h93c5eab2ab237a69UgN::v0.11.0.pre
10: 0x7fe164e2d160 - middle::ty::type_contents::hd87553be01fd1d64QfN::v0.11.0.pre
11: 0x7fe16520a3c0 - middle::kind::check_item::hfb296b4505eee5adOJQ::v0.11.0.pre
12: 0x7fe16520f9f0 - visit::walk_decl::h17157218454155748735::v0.11.0.pre
13: 0x7fe16520f8f0 - visit::walk_stmt::h2013433038502380431::v0.11.0.pre
14: 0x7fe16520f830 - visit::walk_block::h11844577003690490754::v0.11.0.pre
15: 0x7fe165209490 - middle::kind::check_fn::h978ba03dee808a05fPQ::v0.11.0.pre
16: 0x7fe16520a3c0 - middle::kind::check_item::hfb296b4505eee5adOJQ::v0.11.0.pre
17: 0x7fe16520a3c0 - middle::kind::check_item::hfb296b4505eee5adOJQ::v0.11.0.pre
18: 0x7fe16520d230 - middle::kind::check_crate::hec9303143bcae49c1zQ::v0.11.0.pre
19: 0x7fe16512c200 - util::common::time::h3579776483427610692::v0.11.0.pre
20: 0x7fe16559c590 - driver::driver::phase_3_run_analysis_passes::hdc1852929b3d1f8fITj::v0.11.0.pre
21: 0x7fe165595790 - driver::driver::compile_input::hf2673e6ef850e8e5iJj::v0.11.0.pre
22: 0x7fe165660fb0 - driver::run_compiler::h06f7bdbcca33196abmm::v0.11.0.pre
23: 0x7fe165660ed0 - driver::main_args::closure.93524
24: 0x7fe1656761a0 - driver::monitor::closure.94596
25: 0x7fe165671490 - task::TaskBuilder::try::closure.94359
26: 0x7fe164731ef0 - task::spawn_opts::closure.7814
27: 0x7fe16420d330 - rt::task::Task::run::closure.25292
28: 0x7fe1642728c0 - rust_try
29: 0x7fe16420d280 - rt::task::Task::run::h31ac7cd46a833d08Ajw::v0.11.0.pre
30: 0x7fe164731ca0 - task::spawn_opts::closure.7787
31: 0x7fe1642115b0 - rt::thread::thread_start::hcee82097ba2d401982w::v0.11.0.pre
32: 0x7fe161cb6fa0 - start_thread
33: 0x7fe163e57bc9 - __clone
34: 0x0 -

uname -a:
Linux b 3.14-1-amd64 #1 SMP Debian 3.14.2-1 (2014-04-28) x86_64 GNU/Linux

rustc compiled from 9e244d7 (Fri May 23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions