Skip to content

bug(shell): executor buffers output unbounded and pipelines hang on unbounded producers #929

Closed

Description

@AmitoVrito

Found while reviewing #925.

Two related defects in DirectShellExecutor (src/synapsekit/shell/executor.py):

  1. Unbounded output buffering (OOM/DoS). _run_one and _run_pipeline use process.communicate(), which reads the entire child stdout/stderr into memory. max_output_bytes is applied only afterward in _decode, so the advertised bound is not enforced during reading — a continuous producer (cat /dev/zero, yes) buffers unbounded RAM.

  2. Pipeline hang on an unbounded producer. _run_pipeline runs stages sequentially and buffers each stage fully before starting the next, so yes | head -1 never terminates (yes never receives SIGPIPE because head hasn't started).

Fix: stream stdout/stderr with a hard byte cap that terminates the process on overflow (marking the output truncated), for both single commands and pipeline stages. Add regression tests using an unbounded producer with a small max_output_bytes asserting bounded output and prompt return.

Activity

  1. added
    bug
    on Aug 12, 2026
  2. added 2 commits that reference this issue on Aug 12, 2026
    fbc5503
    3df9ac9
  3. AmitoVrito commented on Aug 12, 2026

    @AmitoVrito
    CollaboratorAuthor

    Fixed in #925 (commit 3df9ac9) — replaced communicate() with a streaming _drain() under a hard byte cap that kills the child at the cap; regression tests cover bounded output and a non-hanging pipeline. CI green. Lands on main when #925 merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions