Skip to content

Arc::<T>::new panics for i128 due to ptr::write alignment precondition #2709

@cicilzx

Description

@cicilzx

Hi, I triggered a panic when calling the safe API pen_ffi::Arc::<T>::new with some types (e.g., i128).

extern crate pen_ffi;
fn main() {
    let x: i128 = 1;
    let _ = pen_ffi::Arc::<i128>::new(x);
}

I'm using pen-ffi = "0.10.23":

[dependencies]
pen-ffi = "0.10.23"
  • OS: Linux x86_64 (Ubuntu)
  • Rust toolchain: nightly-2024-12-15

Command:

cargo +nightly-2024-12-15 run -Zbuild-std

It aborts with:

thread 'main' panicked at .../.rustup/toolchains/nightly-2024-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:218:5:
unsafe precondition(s) violated: ptr::write requires that the pointer argument is aligned and non-null
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

Is pen_ffi::Arc<T> intended to support any T (including i128), or are there alignment restrictions on T?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions