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

Panic in List of length > 4035 #55

Closed
dwightguth opened this issue Nov 30, 2018 · 1 comment
Closed

Panic in List of length > 4035 #55

dwightguth opened this issue Nov 30, 2018 · 1 comment
Assignees

Comments

@dwightguth
Copy link

Consider the following program:

extern crate im_rc;

fn main() {
    let mut l = im_rc::Vector::singleton(0);
    for _ in 0..4036 {
      let mut tmp = im_rc::Vector::singleton(0);
      tmp.append(l);
      l = tmp;
    }
    let len = l.len();
    l.slice(1..len);
  }

I would expect this program to terminate without panicking, but instead I get the following panic:

thread 'main' panicked at 'attempt to subtract with overflow', /home/dwightguth/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/im-rc-12.2.0/./src/nodes/rrb.rs:754:44
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:511
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:426
   6: rust_begin_unwind
             at libstd/panicking.rs:337
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:92
   8: core::panicking::panic
             at libcore/panicking.rs:53
   9: <im_rc::nodes::rrb::Node<A>>::split
             at /home/dwightguth/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/im-rc-12.2.0/./src/nodes/rrb.rs:754
  10: <im_rc::vector::Vector<A>>::split_off
             at /home/dwightguth/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/im-rc-12.2.0/./src/vector/mod.rs:968
  11: <im_rc::vector::Vector<A>>::slice
             at /home/dwightguth/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/im-rc-12.2.0/./src/vector/mod.rs:1082
  12: rust::main
             at src/main.rs:11
  13: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  14: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  15: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  16: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  17: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  18: main
  19: __libc_start_main
  20: _start

Note that the program works if I reduce the length of the loop to 4035.

@bodil bodil self-assigned this Dec 10, 2018
@bodil bodil closed this as completed in cb431a6 Jan 14, 2019
@bodil
Copy link
Owner

bodil commented Jan 14, 2019

Wow, this turned out to be a monster bug. Thanks for the tricky spot!

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