Skip to content

Conversation

@PaulHigin
Copy link
Contributor

This fixes a rare race condition that can crash the WinRM service when remote sessions are closing.
From the crash stack dump it is clear that the exception comes from a SetThreadProperties call that references an invalid unmanaged data handle which was previously released. The data handle is released when the plugin command instance is closed and the error occurs when two threads contend to close the same object.

The close command and close session operations are designed to be multi-thread safe, but the SetThreadProperties call is done before the atomic check is performed. The fix is to move the SetThreadProperties call after the atomic check to ensure it is only called when the object is in the opened state.

@daxian-dbw daxian-dbw merged commit 136213d into PowerShell:master Feb 27, 2017
@PaulHigin PaulHigin deleted the RaceFix branch February 28, 2017 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants