microsoft / microsoft/WindowsAppSDK

AppInstance redirection has potential to hang forever

Open
#6,521 0 comments 0 reactions 0 assignees View on GitHub
area-Lifecycle needs-triage
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

Due to lack of full support for CommandLineActivatedEventArgs - https://github.com/microsoft/WindowsAppSDK/issues/6431 - I've been augmenting app instance redirection with my own version for that case. One thing I've noticed in examining the code is that it's possible for an instance to hang indefinitely if the instance it's redirecting to is in the process of shutting down. It would be quite easy to mitigate against this.

In this file https://github.com/microsoft/WindowsAppSDK/blob/main/dev/AppLifecycle/AppInstance.cpp, all you would need to do is signal the `cleanupEvent` (if it exists) in the `onInstanceTerminated` handler, and also check that the process is still open just after creating the `cleanupEvent` (else fail). In an ideal world you might also communicate the error to the waiting process (I guess you might need a second event to signal the error or use a memory mapped file), but in my opinion it's probably better for the waiting process to carry on as normal (usually just exit) rather than hang indefinitely in this case.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in dev/AppLifecycle/AppInstance.cpp and trace the app-instance redirection path through cleanupEvent and the onInstanceTerminated handler. Validate the shutdown race described in the issue; the work is done when a target instance closing during redirection cannot leave the waiting instance blocked indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.