Skip to content

fix(cmplog): stop() closes the FIFO drain - #27

Merged
daedalus merged 1 commit into
masterfrom
claude/pytest-suite-fixes-topztw
Sep 27, 2026
Merged

daedalus merged 1 commit into
masterfrom
claude/pytest-suite-fixes-topztw

Conversation

@daedalus

@daedalus daedalus commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #26 review.

  • Sourcery (bug_risk), confirmed in production: CmplogCollector.stop() unlinked the FIFO but never called _FifoDrain.close(), so the drain thread kept polling and both FIFO fds stayed open. FIFO sink is the CLI default, so every run leaked this. stop() now closes the drain and clears log_path (close already unlinks, so the old exists-then-clear path no longer fired). New tests/test_regression_cmplog_fifo_stop.py: regression (fails before, passes after), adversarial double-stop, falsification for file sink.
  • Copilot: collector fixture now requests monkeypatch, so stop() tears down before monkeypatch undoes. Cross-test leakage did not reproduce (autouse _env_isolation in conftest resets env), but order was wrong within the test; verified with --setup-show.

cmplog tests: 199 passed. ruff clean; lizard clean on the new file.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QWiz6zR3X7BQXuQT2m45G4


Generated by Claude Code

Summary by Sourcery

Close the cmplog FIFO drain during collector shutdown to prevent resource leaks.

Bug Fixes:

  • Ensure stopping the cmplog collector closes the FIFO drain, releases its file descriptors, stops its thread, and clears the log path.

Tests:

  • Add regression coverage for FIFO cleanup, repeated stopping, and file-sink behavior.

stop() unlinked the FIFO but never closed _FifoDrain, leaving its
thread polling and both fds open (FIFO sink is the default). Link-order
test fixture now requests monkeypatch so stop() tears down first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWiz6zR3X7BQXuQT2m45G4
@sourcery-ai

sourcery-ai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Fix cmplog FIFO resource leaks by closing the drain during collector shutdown, stopping its thread, releasing both FIFO descriptors, and clearing shutdown state; add targeted regression coverage for cleanup, idempotency, file sinks, and fixture teardown ordering.

Sequence diagram for cmplog collector shutdown cleanup

sequenceDiagram
    participant Collector as CmplogCollector
    participant Drain as _FifoDrain
    participant FIFO as FIFO resources
    participant OS as OS

    Collector->>Collector: stop()
    alt FIFO sink configured
        Collector->>Drain: close()
        Drain->>Drain: stop drain thread
        Drain->>FIFO: close both file descriptors
        Drain->>OS: unlink FIFO
        Collector->>Collector: clear _fifo
        Collector->>Collector: clear log_path
    else File sink configured
        Collector->>OS: exists(log_path)
        Collector->>OS: unlink(log_path)
    end
Loading

File-Level Changes

Change Details Files
Ensure FIFO-backed collectors fully shut down and release resources.
  • Close the FIFO drain during stop, which terminates its thread and closes both file descriptors.
  • Clear the drain reference and log path, relying on drain close to unlink the FIFO.
  • Preserve safe cleanup for file sinks and repeated stop calls.
src/fuzzer_tool/core/cmplog.py
Add regression coverage for FIFO shutdown behavior and fixture teardown ordering.
  • Verify FIFO path removal, drain-thread termination, descriptor closure, and state clearing.
  • Cover double-stop behavior and confirm file sinks do not create a drain.
  • Make the collector fixture depend on monkeypatch so teardown occurs before monkeypatch restoration.
tests/test_regression_cmplog_fifo_stop.py
tests/test_regression_cmplog_asan_link_order.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@daedalus
daedalus marked this pull request as ready for review September 27, 2026 13:47
Copilot AI lite review requested due to automatic review settings September 27, 2026 13:47

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review issues remain.

Review effort: Lite
Findings: None

What changed in this PR

Fixes cmplog FIFO resource leaks during collector shutdown.

Changes:

  • Closes FIFO drain threads and file descriptors in stop().
  • Clears FIFO paths safely.
  • Adds cleanup, idempotency, and file-sink regression tests.
  • Corrects fixture teardown ordering.
File Description
tests/​test_regression_cmplog_fifo_stop.py Covers FIFO cleanup and repeated stopping.
tests/​test_regression_cmplog_asan_link_order.py Ensures teardown precedes monkeypatch restoration.
src/​fuzzer_tool/​core/​cmplog.py Releases FIFO drain resources during shutdown.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@daedalus
daedalus merged commit ceb540f into master Sep 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants