mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-04 10:48:20 +00:00
fix(subprocess): fail the tree probe on a live member it cannot measure
cbm_subprocess_tree_rss_bytes skipped any non-root process it could not measure and still returned OK with a smaller total, so a descendant the platform refused to measure silently dropped out of the RSS watchdog. Now a member is skipped only when the platform says it no longer exists: ESRCH from proc_pid_rusage on macOS, ENOENT or ESRCH for /proc/<pid>/stat on Linux, ERROR_INVALID_PARAMETER from OpenProcess (or an exit code from a handle whose memory query failed) on Windows. Any other failure fails the probe, which the supervisor already turns into resource_probe_failed after three consecutive errors. The root stays strict as before. On macOS the members now come from proc_listpids(PROC_PGRP_ONLY): the old all-process scan read every process with proc_pidinfo, which answers EPERM for every process of another user (178 of 6438 on this machine), so it could not tell a foreign process from an unreadable member and fail-closed semantics would have failed every probe there. Linux keeps its /proc scan; stat files are world-readable on a default mount, and a hidepid=1 mount now fails closed, which the doc states. A test seam makes every non-root measurement fail with one platform error. RED (old skip-any-failure decision): the live-member test returns OK where ERROR is required. GREEN with the fix; the exited-member test passes in both, so verified exit races are still ignored. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This commit is contained in:
1 parent
33ae8f382e
commit
c78c077a50
4 files changed
+208
-62
No files matched your search
@@ -60,7 +60,11 @@ quarantine a source file.
|
||||
|
||||
If RSS is enabled and three consecutive probes cannot obtain any trustworthy
|
||||
tree measurement while the root worker is still running, CBM fails closed with
|
||||
`code=resource_probe_failed`.
|
||||
`code=resource_probe_failed`. A probe is untrustworthy as soon as one member of
|
||||
the tree cannot be measured: only a process that exits between the listing and
|
||||
its measurement is skipped, because a total without a live member would
|
||||
under-report. On Linux the probe reads every `/proc/<pid>/stat` to find the
|
||||
tree's members, so a `/proc` mounted with `hidepid=1` makes it fail closed.
|
||||
|
||||
## Counting and failure semantics
|
||||
|
||||
|
||||
Reference in new issue
Block a user