-
Notifications
You must be signed in to change notification settings - Fork 18.9k
runtime: bypass reading /proc/self/cgroup and /proc/self/mountinfo when GODEBUG=containermaxprocs=0 #77911
Description
Hello,
The container-aware GOMAXPROCS that was introduced in go1.25 tries to read /proc/self/cgroup and /proc/self/mountinfo at startup.
These reads cause permission denials, when Go binaries built using go1.25 or later are run in a confined environment like snaps. Looking at the init function defaultGOMAXPROCSinit, I can see that /proc/self/cgroup and /proc/self/mountinfo are read unconditionally.
The GOMAXPROCS documentation shows that setting GODEBUG=containermaxprocs=0 and GODEBUG=updatemaxprocs=0 should disable context aware GOMAXPROCS and use runtime.NumCPU as the default value for the number of CPUs. However, since cgroup.OpenCPU runs every time on startup, we do not have an effective way to bypass this behavior using GODEBUG environment variables.
Would it be possible to allow for GODEBUG=containermaxprocs=0 to completely bypass the file reads and use runtime.NumCPU instead?
Thank you!
Metadata
Metadata
Assignees
Labels
Type
Projects
Status