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

Crash on large result #19

Closed
hepek opened this issue Jul 2, 2019 · 3 comments
Closed

Crash on large result #19

hepek opened this issue Jul 2, 2019 · 3 comments

Comments

@hepek
Copy link
Contributor

hepek commented Jul 2, 2019

When an expression value is large enough the application crashes.

> 2000000000*200000000*20000000
thread 'main' panicked at 'index out of bounds: the len is 36 but the index is 9223372036854775808', /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2686:10
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: rust_begin_unwind
             at src/libstd/panicking.rs:308
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::panicking::panic_bounds_check
             at src/libcore/panicking.rs:61
   9: eva::format::pprint
  10: eva::main
  11: std::rt::lang_start::{{closure}}
  12: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:293
  13: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  14: std::rt::lang_start_internal
             at src/libstd/panicking.rs:272
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  15: main
  16: __libc_start_main
  17: _start
@hepek
Copy link
Contributor Author

hepek commented Jul 2, 2019

src/format/mod.rs:38

let mut integral = number.abs().trunc() as i64;

will overflow if number is greater than 2^63+1 giving negative number, which then breaks the modulo indexing logic down at line 41.

@hepek
Copy link
Contributor Author

hepek commented Jul 2, 2019

here's a pull request for this problem: #20

Really like the project, btw. Keep up the good work.

@nerdypepper
Copy link
Owner

sweet! thank you so much for the contribution, ive been meaning to handle this panic for a while, with something like bigint!

closed by #20

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