Skip to content

Bug: qfcformcontroller-cleanup-disposal-ordering #621

Closed as not planned
Closed as not planned

Description

@drmoisan
  • Work Mode: minor-audit

Summary

QfcFormController.Cleanup() tears down state the undo consumer is still using, without first stopping that consumer. QuickFiler/Controllers/QfcFormController.SetupDisposal.cs:216-220 disposes _undoQueue and nulls _globals and _groups while never cancelling or awaiting _undoConsumerTask. A consumer iteration still in flight can therefore observe a disposed queue or a null global, producing an ObjectDisposedException or a NullReferenceException on a background task during teardown.

Environment

  • OS/version:
  • Python version:
  • Command/flags used:
  • Data source or fixture:

Steps to Reproduce

  1. Start the undo consumer so _undoConsumerTask is running and blocked on a take.
  2. Invoke Cleanup() while that iteration is in flight.
  3. Observe the consumer touching _undoQueue, _globals or _groups after QuickFiler/Controllers/QfcFormController.SetupDisposal.cs:216-220 has disposed or nulled them.

Expected Behavior

Cleanup cancels the consumer, awaits _undoConsumerTask to a terminal state, and only then disposes the queue and releases _globals and _groups.

Actual Behavior

Cleanup disposes and nulls first and never awaits the task, so teardown races the consumer.

Logs / Screenshots

  • Attached minimal logs or screenshot
  • Snippet:

Impact / Severity

  • Medium

Race confined to teardown, but it can surface as an unobserved background task exception.

Source

From: docs/features/potential/2026-08-26-qfcformcontroller-cleanup-disposal-ordering.md

Activity

  1. drmoisan commented on Aug 26, 2026

    @drmoisan
    OwnerAuthor

    The promotion tool maps only a subset of the potential-entry headings into the issue body; ## Suspected Cause / Notes and ## Proposed Fix / Validation Ideas were dropped. Restoring them here so the provenance and the remediation ideas are not lost.

    Suspected Cause / Notes

    Discovered during issue #446 (docs/features/active/quickfiler-bug-family-446), which fixed the consumer loop's own termination and its finally reset but did not change Cleanup(). QuickFiler/Controllers/QfcFormController.SetupDisposal.cs was outside #446's owned file set.

    Proposed Fix / Validation Ideas

    • Cancel the consumer's token, then await _undoConsumerTask (with a bounded timeout) before disposing _undoQueue
    • Unit coverage driving Cleanup() against an in-flight consumer, asserting no exception escapes and the task reaches a terminal state
    • Confirm Cleanup() remains safe when the consumer was never started
  2. drmoisan commented on Sep 2, 2026

    @drmoisan
    OwnerAuthor

    Superseded by consolidated issue #731, which tracks this finding along with 4 related ones sharing the same blast radius (QuickFiler controller lifecycle/disposal). See #731 for detail.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions