Crash dumps have shown that Runspace.Close() operation can crash a process if the final two runspaces of a session are closed at the same time. This is because a transcription may be closed/disposed by two separate threads, resulting in a IO or Disposed exception.
https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs#L1176
The Dispose method should be idempotent and if the underlying writer object is disposed or file is closed, the method should not throw.
The problem was found in Windows PowerShell, but the fix (wrap in try/catch) should be applied here as well.
Environment data
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Crash dumps have shown that Runspace.Close() operation can crash a process if the final two runspaces of a session are closed at the same time. This is because a transcription may be closed/disposed by two separate threads, resulting in a IO or Disposed exception.
https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs#L1176
The Dispose method should be idempotent and if the underlying writer object is disposed or file is closed, the method should not throw.
The problem was found in Windows PowerShell, but the fix (wrap in try/catch) should be applied here as well.
Environment data