mangoapp aborts via uncaught ghc::filesystem::filesystem_error (EACCES) when the focused window's process is non-dumpable
Summary
mangoapp crashes with SIGABRT whenever the currently-focused window belongs to a process that is non-dumpable (e.g. it was execve'd from a binary carrying a file capability, such as cap_sys_nice). The crash repeats every time the overlay session manager (e.g. gamescope-session-plus) respawns it, since the same window stays focused — a permanent crash-loop, not a one-off.
Backtrace (from a coredump, terra-mangohud-0.8.4-2.fc44, mangoapp built with debug symbols retained):
#0 raise
#1 abort
#2 __gnu_cxx::__verbose_terminate_handler()
#3 __cxxabiv1::__terminate(void (*)())
#4 std::terminate()
#5 __cxa_throw
#6 ghc::filesystem::directory_iterator::directory_iterator(path const&) [cold path]
#7 GPU_fdinfo::find_fd()
#8 AMDGPU::metrics_polling_thread()Exception payload: ghc::filesystem::filesystem_error: Permission denied: '/proc/<pid>/fdinfo'
Root cause
GPU_fdinfo::find_fd() walks /proc/*/fd (and reads /proc/<pid>/fdinfo/*) to find which processes hold GPU device fds. When the target PID's process is non-dumpable — which the kernel sets automatically for any process executed from a binary with a file capability (security.capability xattr), the same mechanism as a setuid binary — /proc/<pid>/fdinfo becomes unreadable to every other process, including ones running as the same UID (see ptrace_may_access/fs/proc/base.c's dumpable check). ghc::filesystem::directory_iterator's constructor throws filesystem_error on that EACCES, and nothing in find_fd() or its caller (AMDGPU::metrics_polling_thread()) catches it, so the exception reaches std::terminate().
Why this is easy to hit in practice
Bazzite/SteamOS-style sessions run some compositor components (e.g. kwin_wayland, when a nested/KDE session is used) with cap_sys_nice set for real-time scheduling. Any such process, if it ever becomes the focused window mangoapp is sampling, triggers this every polling tick — a continuous crash-loop for as long as it has focus, not an intermittent race.
Suggested fix
Catch filesystem_error (or the specific EACCES/EPERM error codes) around the directory_iterator construction in find_fd() and treat it like a PID that can't be read right now — skip it and continue, the same way a PID that has already exited (ENOENT) presumably should be handled. Alternatively, use the non-throwing directory_iterator(path, error_code&) overload instead of the throwing constructor.
Environment
- Bazzite (
ghcr.io/ublue-os/bazzite-deck:stable),terra-mangohud-0.8.4-2.fc44 - Framework Desktop (Ryzen AI Max 385 / Radeon 8050S, RADV
STRIX_HALO) - Reproduced under
gamescope-session-plus, focused window = a nestedkwin_waylandwithcap_sys_nice=epset on the binary
Repro
Give focus to any window whose process was execve'd from a binary with a file capability set (e.g. sudo setcap cap_sys_nice=ep $(which kwin_wayland) then run and focus it) while mangoapp is active — it aborts on the next GPU-metrics polling tick and keeps aborting on every respawn as long as that window stays focused.
We hit this downstream in a Steam splitscreen launcher (aradanmn/MinecraftSplitscreenSteamdeck#198) and worked around it on our end by running the affected nested compositor under setpriv --no-new-privs, which keeps it dumpable — but that's only viable for processes we control the exec of, not a general fix.
Source: flightlessmango/MangoHud