Title: Get-Error can hang on certain exceptions · Issue #21083 · PowerShell/PowerShell · GitHub
Open Graph Title: Get-Error can hang on certain exceptions · Issue #21083 · PowerShell/PowerShell
X Title: Get-Error can hang on certain exceptions · Issue #21083 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/21083
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Get-Error can hang on certain exceptions","articleBody":"### Prerequisites\n\n- [X] Write a descriptive title.\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [X] Search the existing issues.\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nThere 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.\r\n\r\nI've narrowed it down to the formatting of this particular error record in the formatting code https://github.com/PowerShell/PowerShell/blob/b2ba58442353e740d5e2a45a804da6cfef6c21a3/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs#L831. 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`.\n\n### Expected behavior\n\n```console\nAdd-Type -Assembly System.Data.SqlClient\r\n\r\n# This will raise an exception\r\n[System.Data.SqlClient.SqlCredential].Assembly.GetTypes()\r\n\r\n# Calling Get-Error after \"hangs\"\r\nGet-Error\n```\n\n\n### Actual behavior\n\n```console\nShows the error without hanging\n```\n\n\n### Error details\n\n```console\nNothing, it hangs\n```\n\n\n### Environment data\n\n```powershell\nName Value\r\n---- -----\r\nPSVersion 7.4.1\r\nPSEdition Core\r\nGitCommitId 7.4.1\r\nOS Arch Linux\r\nPlatform Unix\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\n```\n\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/jborean93","@type":"Person","name":"jborean93"},"datePublished":"2024-01-17T00:45:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/21083/PowerShell/issues/21083"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:33b9e685-5148-d00e-3800-f8aca12aa7b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D664:1F16A9:7C810A:B439FF:6A56170C |
| html-safe-nonce | e9f84f898c5f9515c20817899159498511ed09596b18b87abae5c50c88af6c77 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjY0OjFGMTZBOTo3QzgxMEE6QjQzOUZGOjZBNTYxNzBDIiwidmlzaXRvcl9pZCI6IjE0MDIxOTU3MzAzMDM5NDg1NTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5f7e6980377e61bd3786688251f848f45f2526d12274f9f1ab027f66bea06656 |
| hovercard-subject-tag | issue:2085194314 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/21083/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fddd8deb2baca52f9094e9c8809485742105846d352f3c10f9df134249890595/PowerShell/PowerShell/issues/21083 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fddd8deb2baca52f9094e9c8809485742105846d352f3c10f9df134249890595/PowerShell/PowerShell/issues/21083 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jborean93 |
| hostname | github.com |
| expected-hostname | github.com |
| None | f4368738fc918fecd9b3958f6b49218bbe60d4185f38e72e3954e11f1ad0213a |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b76b9cc70d30da50674184c9c66c56423fd0b93c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width