Skip to content

Porting random hang fixes - #5258

Merged
Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:masterfrom
PaulHigin:port-hang-fixes
Nov 10, 2017
Merged

Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:masterfrom
PaulHigin:port-hang-fixes

Conversation

@PaulHigin

Copy link
Copy Markdown
Contributor

These are two fixes for random hangs found internally.

The first fix (job.cs) is for data stream Close calls on PSDataCollection objects because the method also raises public events. If an exception is thrown on the event handler then the thread never completes job clean up causing a hang. Fix is to catch all thrown exceptions and report.

The second (invokecommandcommand.cs) fixes a hang scenario where a remote job goes into disconnected state while simultaneously handling an exception. Fix is to use try/finally pattern to ensure Invoke-Command can always complete with jobs in the disconnected state.

@adityapatwardhan

Copy link
Copy Markdown
Member

Paul Higinbotham (@PaulHigin) Is it possible to add tests for this?

@PaulHigin

Copy link
Copy Markdown
Contributor Author

Aditya Patwardhan (@adityapatwardhan) No, not safely. The code closes all opened runspaces when an "interactive host" runspaces closes, which unfortunately includes Pester runspaces.

@PaulHigin

Copy link
Copy Markdown
Contributor Author

Aditya Patwardhan (@adityapatwardhan) Whoops, I though this was referring to the recent PowerShell hang on exit issue. But again, the answer is not to tests since this is fixing rare random hangs. I might be able to add test hooks, but I don't know if it is worth it.

@SteveL-MSFT

Copy link
Copy Markdown
Member

We should just take this PR into account when we develop reliability specific tests as part of #4008

@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) merged commit 73188ce into PowerShell:master Nov 10, 2017
@PaulHigin
Paul Higinbotham (PaulHigin) deleted the port-hang-fixes branch January 23, 2018 16:46
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WG-Remoting PSRP issues with any transport layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants