Repository navigation
Description
Problem
With use_namespaces, when an action looks up its own child in /proc/<pid> using the PID it got from fork or subprocess, it reads whichever host process has that number, or nothing.
In my case, a profiler records which Python it's running under by reading /proc/<its own PID>/exe. That path belongs to an unrelated host process, so the read fails with PermissionError and the profiler exits before it starts its target.
Present in v1.7.7, v1.8.0 and main.
Cause
The action runs in a new PID namespace, but /proc is still the host's, which lists processes by their host PIDs.
Workaround
An entrypoint script that runs the action under unshare --user --map-current-user --pid --fork --kill-child --mount-proc, which gives it a matching /proc.
Repro
config.json5 (replace /path/to/data):
{
stores: [
{
name: "CAS",
fast_slow: {
fast: {
filesystem: {
content_path: "/path/to/data/cas",
temp_path: "/path/to/data/cas-tmp",
},
},
slow: { noop: {} },
},
},
{ name: "AC", memory: {} },
],
schedulers: [{ name: "SCHEDULER", simple: {} }],
workers: [
{
local: {
worker_api_endpoint: { uri: "grpc://127.0.0.1:50061" },
cas_fast_slow_store: "CAS",
upload_action_result: { ac_store: "AC" },
work_directory: "/path/to/data/work",
platform_properties: {},
use_namespaces: true,
},
},
],
servers: [
{
listener: { http: { socket_address: "127.0.0.1:50051" } },
services: {
cas: [{ cas_store: "CAS" }],
ac: [{ ac_store: "AC" }],
bytestream: [{ cas_store: "CAS" }],
execution: [{ cas_store: "CAS", scheduler: "SCHEDULER" }],
capabilities: [{ remote_execution: { scheduler: "SCHEDULER" } }],
},
},
{
listener: { http: { socket_address: "127.0.0.1:50061" } },
services: { worker_api: { scheduler: "SCHEDULER" } },
},
],
}A Bazel workspace with an empty MODULE.bazel and this BUILD.bazel, which starts sleep 10 and reads its command line from /proc:
genrule(
name = "proc",
outs = ["proc.out"],
cmd = "python3 -c 'import os, sys, time; child = os.fork() or os.execvp(\"sleep\", [\"sleep\", \"10\"]); time.sleep(1); cmdline = open(f\"/proc/{child}/cmdline\", \"rb\").read(); os.kill(child, 9); print(child, cmdline, file=sys.stderr); sys.exit(cmdline != b\"sleep\\0\" b\"10\\0\")' && touch $@",
)nativelink config.json5 &
bazel build --remote_executor=grpc://127.0.0.1:50051 //:proc
With NativeLink v1.8.0 and Bazel 9.3.0 on Linux 7.2, the action fails. The child is PID 3, and /proc/3 is a host kernel thread:
3 b''
With use_namespaces: false, the same action succeeds and prints <pid> b'sleep\x0010\x00'.
Suggested Solution
The worker could mount a new proc over /proc for the action after joining the PID namespace. The action can't do it itself: it runs as a non-root user in the user namespace and has no capabilities after exec.
Activity
MarcusSorealheis commentedon Oct 22, 2026
I'm looking to reproduce this issue now. Thanks for the report @mkanat
Give a namespaced action a /proc that matches its PID namespace (Trac…