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

from_str panic #62

Closed
probablykasper opened this issue Nov 22, 2020 · 2 comments
Closed

from_str panic #62

probablykasper opened this issue Nov 22, 2020 · 2 comments

Comments

@probablykasper
Copy link

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/github.com-1ecc6299db9ec823/decimal-2.0.4/src/dec128.rs:482
   5: decimal::dec128::CTX::__init
             at /Users/kasper/.cargo/registry/src/github.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/github.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/github.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.
@probablykasper
Copy link
Author

This issue doesn't happen for Rust versions before 1.48.0. I believe this PR causes the panic.

@probablykasper
Copy link
Author

Duplicate of #59

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

1 participant