Prerequisites
Steps to reproduce
There is something about the exception raised by Assembly.GetTypes() that is causing Get-Error to get stuck in some loop and use up all system resources. In dotnet 8 loading the System.Data.SqlClient causes an error when attempting to get the types of that assembly. While this is a known problem attempting to use Get-Error to produce more information causes the shell to hang and start to consume all the system resources.
I've narrowed it down to the formatting of this particular error record in the formatting code
. You can run this in pwsh with
https://gist.github.com/jborean93/54a9c7fc999b13ddddaf36d716fe7916 to be able to step through the code that hangs. I haven't figured out what property on this particular exception is actually causing the problem but there is something there. My money is on
Types or
LoaderExceptions in
$Error[0].Exception.InnerException.
Expected behavior
Add-Type -Assembly System.Data.SqlClient
# This will raise an exception
[System.Data.SqlClient.SqlCredential].Assembly.GetTypes()
# Calling Get-Error after "hangs"
Get-Error
Actual behavior
Shows the error without hanging
Error details
Environment data
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Arch Linux
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
There is something about the exception raised by
Assembly.GetTypes()that is causingGet-Errorto get stuck in some loop and use up all system resources. In dotnet 8 loading theSystem.Data.SqlClientcauses an error when attempting to get the types of that assembly. While this is a known problem attempting to useGet-Errorto produce more information causes the shell to hang and start to consume all the system resources.I've narrowed it down to the formatting of this particular error record in the formatting code
PowerShell/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Line 831 in b2ba584
TypesorLoaderExceptionsin$Error[0].Exception.InnerException.Expected behavior
Actual behavior
Shows the error without hangingError details
Nothing, it hangsEnvironment data
Visuals
No response