fix(core): don't terminate on exceptions escaping background tasks - #177
Draft
doogie99 wants to merge 1 commit into
Draft
fix(core): don't terminate on exceptions escaping background tasks#177doogie99 wants to merge 1 commit into
doogie99 wants to merge 1 commit into
Conversation
Worker threads only caught std::bad_alloc; any other exception thrown during page processing unwound to QThread's start wrapper and aborted the whole application via std::terminate(). Catch std::exception in LoadFileTask and surface it as an in-app error page, and add catch-all safety nets in WorkerThreadPool and BackgroundExecutor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
Worker threads only catch
std::bad_alloc. Any other exception thrown during page processing — and the output/dewarping pipeline alone has dozens of throw sites (RasterDewarper,LinearSolver,OutputGenerator's margin checks, etc.) — unwinds to QThread's start wrapper and aborts the entire application viastd::terminate(). The user loses their session with no indication of what went wrong.We hit this in practice on macOS/arm64: before #30 was fixed,
fillMarginsInPlace: the content area exceeds image rect.crashed the app when switching from the dewarping view to output. Any remaining or future throw site can still take the whole app down the same way.Fix
LoadFileTask::operator(): catchstd::exceptionaround the processing chain and return anErrorResultthat displays the exception message in the image area, so the user sees what failed on which page instead of losing the app.std::bad_allocis rethrown so the existing out-of-memory handling still works.WorkerThreadPool/BackgroundExecutor: catch-all safety nets that log a warning instead of terminating.Testing
Built and ran on macOS 26 (arm64, Qt 6.11). Before the #30 fix existed, this change converted the hard crash above into a visible per-page error message — which is also how the root cause was identified.
🤖 Generated with Claude Code