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

cargo-careful panics due to stat being left uninitialized #303

Closed
Deewiant opened this issue Oct 11, 2022 · 1 comment
Closed

cargo-careful panics due to stat being left uninitialized #303

Deewiant opened this issue Oct 11, 2022 · 1 comment

Comments

@Deewiant
Copy link

https://github.com/RalfJung/cargo-careful triggers a panic attempted to leave type `libc::unix::linux_like::linux::gnu::b64::x86_64::stat` uninitialized, which is invalid from within ipc-channel.

Easily reproduced by sending an IpcReceiver over an IpcOneShotServer. For instance:

use ipc_channel::ipc::{self, IpcOneShotServer, IpcReceiver, IpcSender};
fn main() -> Result<(), Box<dyn ::std::error::Error>> {
    let (server, name) = IpcOneShotServer::new()?;
    let (tx, rx) = ipc::channel::<i32>()?;
    IpcSender::connect(name.clone())?.send(rx)?;
    tx.send(1)?;
    let rx2: IpcReceiver<i32> = server.accept()?.1;
    let x = rx2.recv()?;
    println!("connected via {} and got {}", name, x);
    Ok(())
}

Then:

$ RUST_BACKTRACE=1 cargo +nightly careful run
Preparing a careful sysroot (target: x86_64-unknown-linux-gnu)... done
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/bug`
thread 'main' panicked at 'attempted to leave type `libc::unix::linux_like::linux::gnu::b64::x86_64::stat` uninitialized, which is invalid', /.../.cargo/registry/src/github.com-1ecc6299db9ec823/ipc-channel-0.16.0/src/platform/unix/mod.rs:1118:22
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::mem::uninitialized
             at /.../.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:691:9
   4: ipc_channel::platform::unix::is_socket
             at /.../.cargo/registry/src/github.com-1ecc6299db9ec823/ipc-channel-0.16.0/src/platform/unix/mod.rs:1118:22
   5: ipc_channel::platform::unix::recv
             at /.../.cargo/registry/src/github.com-1ecc6299db9ec823/ipc-channel-0.16.0/src/platform/unix/mod.rs:947:16
   6: ipc_channel::platform::unix::OsIpcReceiver::recv
             at /.../.cargo/registry/src/github.com-1ecc6299db9ec823/ipc-channel-0.16.0/src/platform/unix/mod.rs:145:9
   7: ipc_channel::platform::unix::OsIpcOneShotServer::accept
             at /.../.cargo/registry/src/github.com-1ecc6299db9ec823/ipc-channel-0.16.0/src/platform/unix/mod.rs:650:59
   8: ipc_channel::ipc::IpcOneShotServer<T>::accept
             at /.../.cargo/registry/src/github.com-1ecc6299db9ec823/ipc-channel-0.16.0/src/ipc.rs:782:13
   9: bug::main
             at ./src/main.rs:7:33
  10: core::ops::function::FnOnce::call_once
             at /.../.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:251:5

Whereas without cargo-careful there is no problem:

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/bug`
connected via /tmp/.tmpaoO7IE/socket and got 1

I suppose this would be fixed by #280 replacing that mem::uninitialized() with MaybeUninit. Still, I figured I'd report this for visibility in case anybody else runs into it.

@mrobinson
Copy link
Member

I'm not seeing this one any longer.

@mrobinson mrobinson closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
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

2 participants