Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`IO.appPath` fails when `/proc` belongs to another PID namespace

Open Beginner friendly
#15,692 0 comments 3 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, linux

Research direction

Start in src/runtime/io.cpp, in lean_io_app_path, where the executable path is read from /proc/<getpid()>/exe. Check the readlink call and the error path that produces 'failed to locate application'. Reproduce with unshare --user --map-root-user --pid --fork lean --version. Done when lean --version prints the version inside that PID namespace and the existing app-path behaviour still works outside it.

Written by the indexing model from the issue text.

Description

bug
Prerequisites
Description

On Linux, lean_io_app_path (src/runtime/io.cpp) reads /proc/<getpid()>/exe. In a PID namespace without its own /proc mount, getpid() returns the PID inside the namespace, while /proc lists the PIDs of the parent namespace. The path then names another process or none, readlink fails, and every tool that needs IO.appPath fails, including lean and lake.

Context

Sandboxes and rootless containers often run processes in a PID namespace without remounting /proc. In such a sandbox, lean --version fails while other tools work.

Steps to Reproduce
  1. unshare --user --map-root-user --pid --fork lean --version

Expected behavior: Lean prints its version.

Actual behavior: error: failed to locate application

Versions

Lean (version 4.31.0, x86_64-unknown-linux-gnu, commit 68218e876d2a38b1985b8590fff244a83c321783, Release)
Linux 7.2.9

The code on master is unchanged.

Additional Information

/proc/self/exe resolves correctly in this setup, because the kernel resolves self in the namespace of the /proc mount. Reading it instead fixes the problem:

if (readlink("/proc/self/exe", dest, PATH_MAX - 1) == -1) {

As a workaround, an LD_PRELOAD shim can redirect readlink("/proc/<getpid()>/exe") to /proc/self/exe.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Dominant language
Lean
Stars
9.5k
Forks
1k
Avg merge
1d 4h
Merged PRs (30d)
270

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from leanprover/lean4

All issues in leanprover/lean4

Similar issues

More Operating Systems issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.