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

rustc "unexpected panic"; no /proc/self/exe inside a debootstrap chroot #46090

Open
nigeltao opened this issue Nov 19, 2017 · 7 comments
Open
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-linux Operating system: Linux T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nigeltao
Copy link

I installed rustc in a Debian chroot, as per https://wiki.debian.org/Debootstrap

sudo debootstrap testing /debian-testing-chroot https://deb.debian.org/debian/

Inside that chroot, rustc crashes.

# rustc hello.rs
Can't read /proc/cpuinfo: No such file or directory
error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.21.0 running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'failed to get current_exe: no /proc/self/exe available. Is /proc mounted?', src/librustc/session/filesearch.rs:169:22
note: Run with `RUST_BACKTRACE=1` for a backtrace.

# ls /proc
#

Sure, I can tinker with my chroot configuration to flesh out /proc, but as rustc's output said, "the compiler unexpectedly panicked. this is a bug".

@nigeltao
Copy link
Author

RUST_BACKTRACE=1 doesn't give much information.

# RUST_BACKTRACE=1 rustc hello.rs
Can't read /proc/cpuinfo: No such file or directory
error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.21.0 running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'failed to get current_exe: no /proc/self/exe available. Is /proc mounted?', src/librustc/session/filesearch.rs:169:22
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 19, 2017
@XAMPPRocky XAMPPRocky added O-linux Operating system: Linux T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 19, 2018
@guysoft
Copy link

guysoft commented Apr 8, 2021

Getting the same when building cryptography for python.

rustc' panicked at 'failed to get current_exe: no /proc/self/exe available. Is /proc mounted

Source at this project:
https://github.com/guysoft/MagicMirrorOS

@filippoSelvatici
Copy link

filippoSelvatici commented Sep 30, 2021

I'm having the same issue when compiling a simple rust program inside a sandbox. The error I get is:

error: Unable to proceed. Could not locate working directory.: no /proc/self/exe available. Is /proc mounted?

The simple rust program I'm trying to compile is:

fn main() { 
    println!("Hey there!"); 
}

Is there any workaround to avoid mounting proc inside the sandbox?

Source of the sandbox:
https://github.com/alerighi/tabox

@bjorn3
Copy link
Member

bjorn3 commented May 15, 2022

We need /proc/self/exe to implement std::env::current_exe() which rustc uses to locate the sysroot.

@DemiMarie
Copy link
Contributor

@bjorn3 that is going to be a problem, because some sandboxes (such as Sandstorm) deliberately avoid mounting /proc to reduce attack surface. I think rustc should have a compiled-in fallback if /proc is not mounted.

@bjorn3
Copy link
Member

bjorn3 commented May 25, 2022

You can pass --sysroot to manually specify the sysroot location. Rustc can't have a builtin fallback as there is no stamdard location to install it. Some put it in /usr, others in /usr/local amd rustup puts it in ~/.rustup/toolchains/<toolchain name>.

@bjorn3
Copy link
Member

bjorn3 commented May 25, 2022

Also note that libc itself needs /proc to be mounted for certain things. For example musl libc needs it for ttyname and both glibc and musl need it for fchmodat. In both cases to pass an fd to a syscall expecting a path using /proc/self/fd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-linux Operating system: Linux T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants