Description
Our tests started failing after an upgrade to https://crates.io/crates/lexical-write-float/1.0.4
They work with https://crates.io/crates/lexical-write-float/1.0.3 (we reverted to 1.0.3 and so we are not blocked)
We are seeing a panic happen in code changed in 6b518e5
/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/jeaiii.rs:304:29:
range end index 20 out of range for slice of length 19
Prerequisites
Here are a few things you should provide to help me understand the issue:
- Rust version:
rustc 1.83.0 (90b35a623 2024-11-26)
- lexical version: 1.0.3 ( lexical-write-float
1.0.4 )
- lexical compilation features used:
["write-integers", "write-floats", "parse-integers", "parse-floats"
Test case
Example test case. I expect this to work without panic and print i64::MIN to the buffer
use lexical_core::FormattedSize;
fn main() {
// allocate size to write a i64
let mut buf: [u8; i64::FORMATTED_SIZE] = [0; i64::FORMATTED_SIZE];
let data = i64::MIN;
// write the data to the buffer (this panics)
lexical_core::write(data, &mut buf);
}
Run the program above with the latest lexical core
[package]
name = "lexcore-repro"
version = "0.1.0"
edition = "2021"
[dependencies]
lexical-core = "1"
It panics:
/Users/andrewlamb/.cargo/bin/cargo run --color=always --package lexcore-repro --bin lexcore-repro --profile dev
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/lexcore-repro`
thread 'main' panicked at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/jeaiii.rs:304:29:
range end index 20 out of range for slice of length 19
Details
/Users/andrewlamb/.cargo/bin/cargo run --color=always --package lexcore-repro --bin lexcore-repro --profile dev
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/lexcore-repro`
thread 'main' panicked at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/jeaiii.rs:304:29:
range end index 20 out of range for slice of length 19
stack backtrace:
0: rust_begin_unwind
at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
1: core::panicking::panic_fmt
at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
2: core::slice::index::slice_end_index_len_fail_rt
at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/slice/index.rs:64:5
3: core::slice::index::slice_end_index_len_fail
at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/slice/index.rs:58:5
4: <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index_mut
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/index.rs:477:13
5: <core::ops::range::RangeTo<usize> as core::slice::index::SliceIndex<[T]>>::index_mut
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/index.rs:555:9
6: core::slice::index::<impl core::ops::index::IndexMut<I> for [T]>::index_mut
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/index.rs:27:9
7: lexical_write_integer::jeaiii::from_u64
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/jeaiii.rs:304:29
8: <u64 as lexical_write_integer::decimal::Decimal>::decimal
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/decimal.rs:258:17
9: lexical_write_integer::write::WriteInteger::write_integer
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/write.rs:79:9
10: lexical_write_integer::write::WriteInteger::write_mantissa
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/write.rs:22:13
11: lexical_write_integer::api::signed
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/api.rs:58:9
12: <i64 as lexical_write_integer::api::ToLexical>::to_lexical
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-write-integer-1.0.4/src/api.rs:116:27
13: <i64 as lexical_core::ToLexical>::to_lexical
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-core-1.0.3/src/lib.rs:520:17
14: lexical_core::write
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lexical-core-1.0.3/src/lib.rs:609:5
15: lexcore_repro::main
at ./src/main.rs:7:5
16: core::ops::function::FnOnce::call_once
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
After force downgrading lexical-write-integer from latest (1.0.4 to the confusingly non aligned 1.0.3)
[package]
name = "lexcore-repro"
version = "0.1.0"
edition = "2021"
[dependencies]
lexical-core = "1"
# Downgrade to write integer version 1.0.3 works
lexical-write-integer = { version = "=1.0.3" }
The test passes
Additional Context
Add any other context about the problem here.
Description
Our tests started failing after an upgrade to https://crates.io/crates/lexical-write-float/1.0.4
They work with https://crates.io/crates/lexical-write-float/1.0.3 (we reverted to 1.0.3 and so we are not blocked)
We are seeing a panic happen in code changed in 6b518e5
lexical-write-integerupgrade apache/datafusion#13686 for detailsPrerequisites
Here are a few things you should provide to help me understand the issue:
rustc 1.83.0 (90b35a623 2024-11-26)1.0.4)["write-integers", "write-floats", "parse-integers", "parse-floats"Test case
Example test case. I expect this to work without panic and print
i64::MINto the bufferRun the program above with the latest lexical core
It panics:
Details
After force downgrading
lexical-write-integerfrom latest (1.0.4to the confusingly non aligned1.0.3)The test passes
Additional Context
Add any other context about the problem here.