Fail closed on partial FFmpeg worker startup - #143
Draft
Blackspirits wants to merge 1 commit into
Draft
Blackspirits wants to merge 1 commit into
Blackspirits wants to merge 1 commit into
Conversation
Blackspirits
commented
Sep 16, 2026
Blackspirits
left a comment
Owner
Author
There was a problem hiding this comment.
Final adversarial review on 1ad14ddc05f7852ec830ffed9d88bf5913a76334 after CI SubtitleEdit#282: no blocker found. The DisposeLocked extraction preserves teardown ordering; partial worker startup closes already-started workers under the same lifecycle lock; failed Thread.Start accounting is rolled back by #140; the owner removes a failed Session only by CAS and #142 prevents failed/stale startup cleanup from erasing a replacement load. No merge/promotion performed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Dependent startup-lifetime follow-up to #142 ("Fence FFmpeg close cleanup by load generation").
#140 gives Session teardown exact worker accounting and deferred reclamation, and #142 makes owner cleanup generation-safe. This tranche closes the remaining partial-startup boundary: Session.Start publishes/starts four workers sequentially, so a later Thread.Start failure can occur after earlier workers are already alive.
Current upstream
SubtitleEdit/subtitleeditmain was rechecked atd6917286e355976da953d0ee22208b4bf9461699; no relevant drift or competing upstream PR was found.Finding fixed
The Session is published to the owner before
Session.Start().Before this change, worker startup was:
If a later
Thread.Start()throws (for example under severe resource pressure) after earlier workers started,Start()escaped without closing those workers/resources.LoadFile()only handledObjectDisposedException, so the failed Session could remain published with a partial worker set and the load Task could fault.Fix
Worker startup is now all-or-nothing:
Start()keeps the existing lifecycle lock across the whole startup sequence;DisposeLocked(), with its ordering unchanged;_fileNameis cleared only while the failed generation is still current;ObjectDisposedExceptionpath remains reserved for concurrent CloseFile winning startup.#140's worker accounting means a Thread.Start that itself fails has already rolled back its active-worker count; workers that did start are closed/joined or retained fail-closed under the same timeout/reclamation rules.
Validation boundary
A deterministic process-level Thread.Start failure cannot be injected without adding a production-only thread-creation test hook. This tranche deliberately avoids that testability distortion.
Acceptance therefore relies on:
DisposeLocked()preserves the previous Dispose ordering exactly;Scope / branch state
6cfde218dfd95e43e7e12077178e95b6969a57c41ad14ddc05f7852ec830ffed9d88bf5913a76334d6917286e355976da953d0ee22208b4bf9461699AI assistance: ChatGPT was used for adversarial partial-thread-start modelling, lifecycle-lock analysis, rollback ownership review and concurrent replacement cleanup review.
Final CI
Authoritative run: SubtitleEdit#282 on
1ad14ddc05f7852ec830ffed9d88bf5913a76334Final adversarial review was performed on this exact HEAD after CI; no blocker found.