Skip to content

from_str panic #62

Closed
Closed
@probablykasper

Description

@probablykasper

Using d128::from_str causes a panic when running in macOS 11.0.1 Big Sur (not on ARM).

Code:

use std::str::FromStr;
use decimal::d128;

fn main() {
  let x = d128::from_str("2");
  println!("{:?}", x);
}

Output:

bash-3.2$ RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/cpc`
thread 'main' panicked at 'attempted to leave type `context::Context` uninitialized, which is invalid', /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/mem/mod.rs:658:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   2: core::panicking::panic
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:50
   3: core::mem::uninitialized
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/mem/mod.rs:658
   4: decimal::dec128::d128::default_context
             at /Users/kasper/.cargo/registry/src/6github.com-1ecc6299db9ec823/decimal-2.0.4/src/dec128.rs:482
   5: decimal::dec128::CTX::__init
             at /Users/kasper/.cargo/registry/src/6github.com-1ecc6299db9ec823/decimal-2.0.4/src/dec128.rs:26
   6: core::ops::function::FnOnce::call_once
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/ops/function.rs:227
   7: std::thread::local::lazy::LazyKeyInner<T>::initialize
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/local.rs:304
   8: std::thread::local::fast::Key<T>::try_initialize
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/local.rs:473
   9: std::thread::local::fast::Key<T>::get
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/local.rs:456
  10: decimal::dec128::CTX::__getit
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/local.rs:183
  11: std::thread::local::LocalKey<T>::try_with
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/local.rs:271
  12: std::thread::local::LocalKey<T>::with
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/thread/local.rs:248
  13: decimal::dec128::d128::with_context
             at /Users/kasper/.cargo/registry/src/6github.com-1ecc6299db9ec823/decimal-2.0.4/src/dec128.rs:490
  14: <decimal::dec128::d128 as core::str::traits::FromStr>::from_str
             at /Users/kasper/.cargo/registry/src/6github.com-1ecc6299db9ec823/decimal-2.0.4/src/dec128.rs:194
  15: cpc::main
             at ./src/main.rs:5
  16: core::ops::function::FnOnce::call_once
             at /Users/kasper/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions