[GH-ISSUE #2274] [Bug] pwntools cleanup_incomplete omits the retained process group from its resources #755

Closed
opened 2026-10-15 18:28:00 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @kaoru0822-kitauji on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/2274

Observed behavior

When a pwntools/pwndbg provider stage cannot confirm that its owned process group stopped, the cleanup_incomplete result lists only the run ID and the private runtime directory as retained resources. It omits the process the caller would need to inspect:

details.resources:
  ["rea-artifact-decoder-<uuid>", "/…/owned-XXXX"]                     # decoder stage
  ["rea-recorded-core-debugger-<uuid>", "/…/owned-XXXX"]               # debugger stage

In the same scenario a descendant of the retained group is still alive. The existing test asserts process.kill(descendant, 0) does not throw. OwnedCommand's own non-transferred cleanup error reports the same ownership as [runId, cwd, "pid:<leaderPid>", "process-group:<processGroupId>"].

Codex raised this on #1708 after it merged (PwntoolsDecoder.ts:521, "Include the retained process group in cleanup resources"). This issue tracks it with a reproduction.

Reproduction

Current main 11fe5a13f, macOS (the tests simulate the Linux x64 decoder gate and use real owned processes). In tests/process-global/pwntoolsStageRetirement.test.ts, the does not read unresolved $stage files after command $outcome cases produce cleanup_incomplete. Printing projectAnalysisError(result.error).details.resources gives two entries in all four cases, with no pid: or process-group:.

Expected behavior

While the supervisor is retained, the cleanup resources also include pid:<leaderPid> and process-group:<processGroupId> from its launch ownership, matching OwnedCommand.

Cause

PwntoolsDecoder.#retireProcess (src/native/pwntools/PwntoolsDecoder.ts) builds the ProviderCleanupError resources from pending.process.launch.ownership?.runId and pending.root.path only.

Originally created by @kaoru0822-kitauji on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/2274 ### Observed behavior When a pwntools/pwndbg provider stage cannot confirm that its owned process group stopped, the `cleanup_incomplete` result lists only the run ID and the private runtime directory as retained resources. It omits the process the caller would need to inspect: ```text details.resources: ["rea-artifact-decoder-<uuid>", "/…/owned-XXXX"] # decoder stage ["rea-recorded-core-debugger-<uuid>", "/…/owned-XXXX"] # debugger stage ``` In the same scenario a descendant of the retained group is still alive. The existing test asserts `process.kill(descendant, 0)` does not throw. `OwnedCommand`'s own non-transferred cleanup error reports the same ownership as `[runId, cwd, "pid:<leaderPid>", "process-group:<processGroupId>"]`. Codex raised this on #1708 after it merged (`PwntoolsDecoder.ts:521`, "Include the retained process group in cleanup resources"). This issue tracks it with a reproduction. ### Reproduction Current main 11fe5a13f, macOS (the tests simulate the Linux x64 decoder gate and use real owned processes). In `tests/process-global/pwntoolsStageRetirement.test.ts`, the `does not read unresolved $stage files after command $outcome` cases produce `cleanup_incomplete`. Printing `projectAnalysisError(result.error).details.resources` gives two entries in all four cases, with no `pid:` or `process-group:`. ### Expected behavior While the supervisor is retained, the cleanup resources also include `pid:<leaderPid>` and `process-group:<processGroupId>` from its launch ownership, matching `OwnedCommand`. ### Cause `PwntoolsDecoder.#retireProcess` (`src/native/pwntools/PwntoolsDecoder.ts`) builds the `ProviderCleanupError` resources from `pending.process.launch.ownership?.runId` and `pending.root.path` only.
bsakaguchi 2026-10-15 18:28:00 +00:00
Author
Owner

@jeonjw85 commented on GitHub (Oct 12, 2026):

I'll work on this. The retained supervisor already has the launch ownership, so I'll include its leader PID and process-group ID in the cleanup resources and extend the existing stage-retirement tests to check those identities. I'll also check the shared ownership-reporting path to avoid duplicating the resource format.

<!-- gh-comment-id:6129740664 --> @jeonjw85 commented on GitHub (Oct 12, 2026): I'll work on this. The retained supervisor already has the launch ownership, so I'll include its leader PID and process-group ID in the cleanup resources and extend the existing stage-retirement tests to check those identities. I'll also check the shared ownership-reporting path to avoid duplicating the resource format.
Author
Owner

@matbrgz commented on GitHub (Oct 12, 2026):

Triage & Supervision Review

Per AGENTS.md ("Retain ownership of resources whose cleanup failed. Reuse src/process/ supervision and identity primitives"), when process cleanup cannot confirm termination, returning cleanup_incomplete without the retained PID / PGID prevents external supervision or manual triage from reclaiming the stranded process.

  • Fix Contract: details.resources must include "pid:<leaderPid>" and "process-group:<pgid>" in the reported resource list, matching OwnedCommand's standard retention contract.
<!-- gh-comment-id:6134323384 --> @matbrgz commented on GitHub (Oct 12, 2026): ### Triage & Supervision Review Per `AGENTS.md` ("Retain ownership of resources whose cleanup failed. Reuse `src/process/` supervision and identity primitives"), when process cleanup cannot confirm termination, returning `cleanup_incomplete` without the retained PID / PGID prevents external supervision or manual triage from reclaiming the stranded process. - **Fix Contract:** `details.resources` must include `"pid:<leaderPid>"` and `"process-group:<pgid>"` in the reported resource list, matching `OwnedCommand`'s standard retention contract.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#755
No description provided.