Skip to content

"task failed at 'index out of bounds..." when compiling #5754

Closed
@hdgarrood

Description

@hdgarrood

rustc says this is a bug, so here goes:

Here's the code I'm trying to compile:

// chipmunk.rs
pub mod ll {
    struct cpVect {
        x: float,
        y: float
    }

    pub extern {
        fn cpv(x: int, y: int) -> cpVect;
        fn cpvadd(vec1: cpVect, vec2: cpVect) -> cpVect;
        static cpvzero: cpVect;
    }
}

fn main() {
    unsafe {
        let vec1 = ll::cpv(30, 40);
        let vec2 = ll::cpv(-23, 35);

        io::println(fmt!("vector sum is %?", ll::cpvadd(vec1, vec2)));
    }
}

And here's what happens when I try to compile:

$ RUST_LOG=rustc=1,::rt::backtrace rustc chipmunk.rs
chipmunk.rs:8:18: 8:21 warning: found rust type `int` in foreign module, while libc::c_int or libc::c_long should be used
chipmunk.rs:8         fn cpv(x: int, y: int) -> cpVect;
                                ^~~
chipmunk.rs:8:26: 8:29 warning: found rust type `int` in foreign module, while libc::c_int or libc::c_long should be used
chipmunk.rs:8         fn cpv(x: int, y: int) -> cpVect;
                                        ^~~
rust: task failed at 'index out of bounds: the len is 2 but the index is 2', /home/harry/build/rust/src/librustc/middle/trans/cabi_x86_64.rs:248
/home/harry/.local/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4b)[0x7fe683313c7b]
/home/harry/.local/bin/../lib/librustrt.so(+0x2aa69)[0x7fe683324a69]
/home/harry/.local/bin/../lib/librustrt.so(upcall_fail+0x1a8)[0x7fe683315a68]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x1055fb)[0x7fe684e4a5fb]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x4d1de)[0x7fe684d921de]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN8unstable4lang17fail_bounds_check16_6fb13a2fe60974b3_06E+0x22f)[0x7fe684d9b53f]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x2f717c)[0x7fe68384d17c]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans11cabi_x86_6414__extensions__10meth_3425112compute_info16_ba1369f44fa5d573_06E+0x16e)[0x7fe68384dcbe]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8b8fb4)[0x7fe683e0efb4]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x2faf53)[0x7fe683850f53]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x2fc42d)[0x7fe68385242d]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x2fc110)[0x7fe683852110]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans7foreign17trans_foreign_mod16_75c1b14fd3764383_06E+0x11e)[0x7fe6837ca1fe]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base10trans_item16_ed7df62f5f126563_06E+0x48d)[0x7fe68366280d]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base9trans_mod17_33f95ffa6ea6f19d3_06E+0xa3)[0x7fe6837c9fe3]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base10trans_item16_ed7df62f5f126563_06E+0x46e)[0x7fe6836627ee]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base9trans_mod17_33f95ffa6ea6f19d3_06E+0xa3)[0x7fe6837c9fe3]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6middle5trans4base11trans_crate15_aa5d2b86af98143_06E+0x13c4)[0x7fe6837e9c94]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x87a6d0)[0x7fe683dd06d0]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_rest17_b2b258b84b35f3533_06E+0x331e)[0x7fe683dcd6de]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8b8fb4)[0x7fe683e0efb4]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver12compile_upto17_12335154b455986e3_06E+0x108)[0x7fe683dd08e8]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8b8fb4)[0x7fe683e0efb4]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN6driver6driver13compile_input15_bb29edf7a232863_06E+0xca)[0x7fe683dd0d2a]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN12run_compiler17_64d52739a36d169c3_06E+0x20aa)[0x7fe683e0044a]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8b6a81)[0x7fe683e0ca81]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8b32ac)[0x7fe683e092ac]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8b8fb4)[0x7fe683e0efb4]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0xce0ae)[0x7fe684e130ae]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x14dcd4)[0x7fe684e92cd4]
/home/harry/.local/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7fe6833144c4]
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', /home/harry/build/rust/src/librustc/rustc.rc:357
/home/harry/.local/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x4b)[0x7fe683313c7b]
/home/harry/.local/bin/../lib/librustrt.so(+0x2aa69)[0x7fe683324a69]
/home/harry/.local/bin/../lib/librustrt.so(upcall_fail+0x1a8)[0x7fe683315a68]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x1055fb)[0x7fe684e4a5fb]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x1055a2)[0x7fe684e4a5a2]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(_ZN3sys12begin_unwind17_61fe198059b9e3fc3_06E+0x71)[0x7fe684d92671]
/home/harry/.local/bin/../lib/libcore-c3ca5d77d81b46c1-0.6.so(+0x14dcd4)[0x7fe684e92cd4]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN7monitor17_78935df9ff9e1afa3_06E+0x1577)[0x7fe683e02a77]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(+0x8b8fb4)[0x7fe683e0efb4]
/home/harry/.local/bin/../lib/librustc-c84825241471686d-0.6.so(_ZN4main15_c4de63b748e03d3_06E+0x7e)[0x7fe683e0ebce]
/home/harry/.local/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7fe6833144c4]
rust: domain main @0xe283c0 root task failed
exit code was 101

I built rust from the tag release-0.6:

$ rustc --version
rustc 0.6 (00dbbd0 2013-04-02 11:07:11 -0700)
host: x86_64-unknown-linux-gnu

The library I'm trying to link with is https://github.com/slembcke/Chipmunk-Physics at version 6.1.4. Also, on the off-chance that it's relevant:

$ cat /etc/lsb-release 
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=14
DISTRIB_CODENAME=nadia
DISTRIB_DESCRIPTION="Linux Mint 14 Nadia"

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