Repository navigation
fix: let the update helper exit, reopen the app and clean up after itself - #40
Merged
Merged
Conversation
The helper relaunches the replaced exe through the shell. When the exe still carries its Zone.Identifier stream, Windows raises Open File - Security Warning inside the hidden helper, so it never exits.
File.Replace keeps the old exe's Zone.Identifier stream, so a shell relaunch prompted in the hidden helper and blocked it forever. The app never reopened and the helper, its download and its extraction folder were left behind on every update.
A helper cannot delete its own running exe, so every update left the helper exe and its extracted native libraries in the temp folder. The app now removes them when it starts, skipping any helper that is still running.
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.
After an update the app never reopened, and the temporary update helper stayed running forever. Each update leaked one helper process, its ~87 MB exe, the downloaded update and a folder of extracted native libraries in the temp folder.
Root cause
The helper was not waiting on the parent process or a file lock. It was stuck on a Windows security prompt nobody could see:
Zone.Identifierstream (the download mark).ReplaceTargetFileswaps the exe withFile.Replace, which keeps the old file's alternate data streams, so every updated exe keeps the mark.TryLaunchreopened the app withUseShellExecute = true, so the shell raised "Open File - Security Warning" for the unsigned, marked exe.CreateNoWindowandWindowStyle.Hidden, so that dialog is created hidden and the helper's main thread blocks on it forever.Confirmed on a machine with 20 leaked helpers: the main thread of each was inside
ShellExecuteExW→CheckSmartScreen→DialogBox, and each owned a hidden dialog with that title.Fix
TryLaunchnow usesUseShellExecute = false, which starts the exe directly and skips the shell's zone check, so there is no prompt to block on.UpdateInstaller.DeleteStaleHelpersremoves them when the app starts its update check. A helper that is still running keeps its exe locked, and its extraction folder is kept with it.Tests
HelperExitsAfterReplacingAnExeThatCarriesTheMarkOfTheWebruns the real built exe in--apply-updatemode against a target markedZoneId=3. It timed out at 30 s before the fix and passes after it.DeleteStaleHelpersRemovesFinishedHelpersAndLeavesRunningOnesAndOtherFileschecks the cleanup takes finished helpers and orphaned extraction folders, and leaves a locked helper, its folder and unrelated files alone.dotnet test src/FourFoldAccountManager.Desktop.Tests: 33 passed.dotnet test src/FourFoldAccountManager.Core.Tests: 310 passed.Also checked by hand with a single-file build published the same way as the release workflow, marked
ZoneId=3and versioned below the latest release: it downloaded the update, the helper exited within a second, the app reopened visibly with no prompt, and the download was deleted. A second build then removed a planted stale helper exe and extraction folder from the temp folder on startup.Not changed
Note on rollout
Installed copies up to v1.1.30 still have the bug in their own helper, so their update to the release containing this fix will leave one last stuck helper and not reopen. Updates from that release onward behave correctly.
Merging publishes a client release, since this touches
src/.