Why is Rust hello world trying to read / proc and / sys

I need to run the Rust executable (made with cargo build --release) inside chroot. I usually just copy files reported by ldd

$ldd hello_world_rust
linux-vdso.so.1 (0x00007ffef48c6000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f3224c3e000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f3224a21000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007f3224819000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f3224603000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f3224261000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3224e42000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f3223f5d000)

But my rust programs crash when run in jail

thread '<unnamed>' panicked at 'assertion failed: `(left == right)` (left: `2`, right: `0`)', /build/rust/src/rustc-1.1.0/src/libstd/sys/unix/thread.rs:204
fatal runtime error: Could not unwind stack, error = 5
Illegal instruction (core dumped)

When checking things with strace (inside the prison) I noticed the following

strace -e file hello_world_rust
.... 14 lines of loading dynlibs cut
readlink("/etc/je_malloc.conf", 0x7fff7c2ed380, 4096) = -1 ENOENT (No such file or directory)
open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/proc/stat", O_RDONLY|O_CLOEXEC)  = -1 ENOENT (No such file or directory)
open("/proc/cpuinfo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/proc/self/maps", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

I believe the crash is due to the lack of / proc and / sys inside the chroot.

Is my opinion true? If so, why are they needed? Is there a way that I can compile my rust program so that it does not need / sys and / proc?

+4
source share
1 answer

I think this is a known issue . According to Alex Crichton:

- . , , linux , .

+2

Source: https://habr.com/ru/post/1598114/


All Articles