bytecodealliance/rustix

`proc_self_status` fails on concurrent calls

niluxv opened this issue · 1 comments

proc_self_status again... It fails when called multiple times concurrently. On versions 0.18.14 and less it works fine, so I suppose this is not expected behaviour. If it is, then that definitely needs to be documented.

Example

const THREADS: usize = 3;

fn self_proc_status() {
    rustix::procfs::proc_self_status().expect("error getting proc/self/status pid");
}

#[test]
fn parallel_self_proc_status() {
    let mut handles = Vec::with_capacity(THREADS);
    for _ in 0..THREADS {
        handles.push(std::thread::spawn(self_proc_status));
    }
    for handle in handles.drain(..) {
        handle.join().expect("thread crashed");
    }
}

Outputs:

---- parallel_self_proc_status stdout ----
thread '<unnamed>' panicked at src/main.rs:6:40:
error getting proc/self/status pid: Os { code: 95, kind: Uncategorized, message: "Operation not supported" }
thread 'parallel_self_proc_status' panicked at src/main.rs:16:23:
[...]