我需要在chroot中运行Rust可执行文件(由cargo build --release
生成)。通常,我只是复制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)
但是我的Rust程序在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)
当用strace检查事物时(在监狱里面),我注意到以下内容
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)
我认为发生崩溃是因为chroot中没有/ proc和/ sys。
我的信念是否正确?如果是这样,为什么他们有必要?有没有办法可以编译我的锈程序,这样它就不需要/ sys和/ proc?
答案 0 :(得分:2)
我相信这是known issue。根据Alex Crichton的说法:
看起来the failure in question是我们在设置第一个防护页面时检测到主线程的堆栈开始。我忘了linux为我们设置一个防护页面的可靠性,至少现在很难删除。