status.py: /proc/<pid>/stat parsing breaks when comm contains spaces/parens (contradicts drain_control.py's own correct parser)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- backend, operating-systems
Research direction
Start in gateway/status.py around line 309 and compare its /proc//stat handling with the parser in gateway/drain_control.py around lines 147-149. Verify that the extracted start time remains field 22 when comm contains spaces and right parentheses, then check the interaction with delivery_ledger.py around line 174. Done means live-owner checks no longer misread processes or permit duplicate claims.
Written by the indexing model from the issue text.
Description
Summary
gateway/status.py (~line 309) reads the process start time with:
int(stat_path.read_text(encoding="utf-8").split()[21])
Whitespace-splitting /proc/<pid>/stat is unsafe: field 2 (comm, parenthesized) may contain spaces and right parens, shifting every subsequent field index. The same repository already documents and handles this correctly in gateway/drain_control.py (~lines 147-149): "comm can contain spaces and parens, so split on the LAST ')'" and indexes the tail — this call site is a leftover.
Impact
Beyond a wrong value or IndexError fallback, if the shifted index lands on a volatile field (e.g. processor number, which changes with CPU migration), two reads of the same live process can yield different values. delivery_ledger._owner_alive() (gateway/delivery_ledger.py ~line 174) would then misjudge a live owner as dead, letting a second gateway process claim its pending/attempting rows — duplicate delivery, which violates that module's "never a silent duplicate" contract.
Suggested fix
Align with drain_control.py:
text = stat_path.read_text(encoding="utf-8")
tail = text.rsplit(")", 1)[1].split()
return int(tail[19]) # field 22 == tail index 19 (tail starts at field 3)
Found auditing v0.20.1 (v2026.8.13).
- Dominant language
- Python
- Stars
- 247k
- Forks
- 52k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NousResearch/hermes-agent
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
P3 tool/tts type/bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
NousResearch/hermes-agent#117794 ·
-
[Bug]: context-limit error parsing has no pattern for llama.cpp's "context size (N tokens)" phrasing Openarea/compression area/local-models area/sessions comp/agent duplicate P2 sweeper:risk-session-state type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NousResearch/hermes-agent#117793 · 1 comment ·
-
comp/cron P2 sweeper:risk-automation type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#117792 · 1 comment ·
-
comp/agent P2 provider/qwen tool/terminal type/bug
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
NousResearch/hermes-agent#117791 ·
All issues in NousResearch/hermes-agent
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100