uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.55k stars 1.26k forks source link

seq: panic when parsing infinitesimal float in scientific notation #3318

Open jfinkels opened 2 years ago

jfinkels commented 2 years ago

Environment: Ubuntu 20.04, x86_64 processor, coreutils v8.30.

GNU seq:

$ seq 1e-9223372036854775808  # terminates immediately with no output and exit status 0

uutils seq

$ ./target/debug/seq 1e-9223372036854775808
thread 'main' panicked at 'attempt to subtract with overflow', /home/jeffrey/.cargo/registry/src/github.com-1ecc6299db9ec823/bigdecimal-0.3.0/src/lib.rs:1676:21

This test case appears in the GNU test suite file tests/misc/seq-precision.sh.

fritzrehde commented 1 year ago

The panic occurs where parsing the big number. It seems like this is a bug in the bigdecimal-rs crate. I filed an issue there. Do you think it would make sense to extend the tests in https://github.com/uutils/coreutils/blob/main/src/uu/seq/src/numberparse.rs that check that test that very small numbers/exponents (those for which the big decimal datastructure is required) are parsed from strings correctly? Or is this the responsibility of the bigdecimal-rs crate, meaning such tests should be added there?

jfinkels commented 11 months ago

Once there is a fix for this bug, I would place a test case in tests/by-util/test_seq.rs that just does something like

#[test]
fn test_parsing_infinitesimal_float_scientific_notation() {
    new_ucmd!().arg("1e-9223372036854775808").succeeds().no_output();
}