René's URL Explorer Experiment


Title: Test-ModuleManifest is not thread safe (exceptions thrown from deep inside PowerShell engine) · Issue #9889 · PowerShell/PowerShell · GitHub

Open Graph Title: Test-ModuleManifest is not thread safe (exceptions thrown from deep inside PowerShell engine) · Issue #9889 · PowerShell/PowerShell

X Title: Test-ModuleManifest is not thread safe (exceptions thrown from deep inside PowerShell engine) · Issue #9889 · PowerShell/PowerShell

Description: PSScriptAnalyzer version of 1.18.0 or older sporadically encounter an exception when calling Test-ModuleManifest concurrently, it seems to be an issue of the PowerShell engine code itself, not the cmdlet The issue applies to any PowerShe...

Open Graph Description: PSScriptAnalyzer version of 1.18.0 or older sporadically encounter an exception when calling Test-ModuleManifest concurrently, it seems to be an issue of the PowerShell engine code itself, not the ...

X Description: PSScriptAnalyzer version of 1.18.0 or older sporadically encounter an exception when calling Test-ModuleManifest concurrently, it seems to be an issue of the PowerShell engine code itself, not the ...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9889

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Test-ModuleManifest is not thread safe (exceptions thrown from deep inside PowerShell engine)","articleBody":"PSScriptAnalyzer version of 1.18.0 or older sporadically encounter an exception when calling `Test-ModuleManifest` concurrently, it seems to be an issue of the PowerShell engine code itself, not the cmdlet\r\nThe issue applies to any PowerShell version (5, 6.2, 7.0-preview1)\r\n\r\nFor context, here is how PSSA calls `Test-ModuleManifest` in the `Singleton` `Helper` class by creating an instance of `PowerShell` each time (that gets disposed afterwards) but with a re-used runspace pool (previous versions did not re-use the runspace pool and suffered from the same issue as well though).\r\nhttps://github.com/PowerShell/PSScriptAnalyzer/blob/0bef1c8b8ddf5b570dd0b6c90f0d0257b94eb374/Engine/Helper.cs#L306-L315\r\n```csharp\r\nusing (var ps = System.Management.Automation.PowerShell.Create())\r\n{\r\n    ps.RunspacePool = _runSpacePool;\r\n    ps.AddCommand(\"Test-ModuleManifest\")\r\n        .AddParameter(\"Path\", filePath)\r\n        .AddParameter(\"WarningAction\", ActionPreference.SilentlyContinue);\r\n    try\r\n    {\r\n        psObj = ps.Invoke();\r\n    }\r\n    { ... }\r\n}\r\n```\r\nThe above code gets called from from different threads (each rule has its own thread) that are started as follows here:\r\nhttps://github.com/PowerShell/PSScriptAnalyzer/blob/a68b13956ab1136af91066d1ce61113574447945/Engine/ScriptAnalyzer.cs#L2075\r\n```csharp\r\nallowedRules.Select(scriptRule => Task.Factory.StartNew(() => .... );\r\n```\r\n\r\n# Steps to reproduce\r\n\r\nExtract the files in the below zip to a folder (yes, they are a bit artificial but are a good and simple way of making the race condition more reliably on most machines (my machine is a 4 core i7).\r\n[repro.zip](https://github.com/PowerShell/PowerShell/files/3287403/repro.zip)\r\n\r\n```powershell\r\nInstall-module PSScriptAnalyzer -RequiredVersion 1.18.0\r\n1..100 | Invoke-ScriptAnalyzer -Path $PathToReproPsd1\r\n```\r\n\r\n# Expected behavior\r\n\r\n```none\r\nNo leaked errors\r\n```\r\n\r\n# Actual behavior\r\n\r\nPowerShell leaks errors that indicate a thread safety problem.\r\nPR #9860 offered a fix but the review concluded it was not the right fix/place.\r\n\r\nThe stack trace is below and I uploaded a minidump with heap [here](https://www.dropbox.com/s/pgblge4chymc8wc/pwsh.dmp?dl=0) from the latest `master` commit `bdc8548700118cea6c31420c2f7478785e6d84ac` of `PowerShell` for one of the most common exceptions (`CmdletInvocationException` with inner exception from `System.Collections.ListDictionaryInternal`:  `'Collection was modified; enumeration operation may not execute.'`)\r\n```\r\n   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\pipelinebase.cs:line 416\r\n   at System.Management.Automation.Runspaces.Pipeline.Invoke() in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\Pipeline.cs:line 531\r\n   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\PowerShell.cs:line 5619\r\n   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync) in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\PowerShell.cs:line 5466\r\n   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings) in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\PowerShell.cs:line 4588\r\n   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings) in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\PowerShell.cs:line 4780\r\n   at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings) in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\PowerShell.cs:line 4530\r\n   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings) in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\PowerShell.cs:line 2425\r\n   at System.Management.Automation.PowerShell.Invoke() in C:\\Users\\chris\\PowerShell\\src\\System.Management.Automation\\engine\\hostifaces\\PowerShell.cs:line 2296\r\n   at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidUsingDeprecatedManifestFields.AnalyzeScript(Ast ast, String fileName)+MoveNext()\r\n```\r\nI wonder if the call to `return Output.NonBlockingRead(Int32.MaxValue);` in [pipelinebase.cs (line 416) ](https://github.com/PowerShell/PowerShell/blob/d80154430d600a52a1d1e3a9f3ecf032b36185d4/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs#L416) would need to be blocking?\r\n\r\n\r\n# Environment data\r\n\r\nWindows (any version, e.g. 1903), Any version of PowerShell (5.1, 6.2, 7.0-prevew1, latest commit from master)","author":{"url":"https://github.com/bergmeister","@type":"Person","name":"bergmeister"},"datePublished":"2019-06-13T17:48:37Z","url":"https://github.com/PowerShell/PowerShell/issues/9889"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a514fe8a-f1a1-56e8-d261-6dd7a64a1e66
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEB7A:1D838C:28CE1:37585:6AFCE8B4
html-safe-nonce73a613571b5be12eaf4943b7726a4e9fb5952032bab3ab37f42db8ec7de1e902
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjdBOjFEODM4QzoyOENFMTozNzU4NTo2QUZDRThCNCIsInZpc2l0b3JfaWQiOiI1Njc2MzY3ODU1NTI0NTcxMzE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac1a84d2fdc0ee06110d387ee008341e64460258f37061ddf2e86991364c65f5c6
hovercard-subject-tagissue:455872725
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/9889/issue_layout
twitter:imagehttps://opengraph.githubassets.com/571155c07b73226aa99f8e91b6356c0d2b547ac4b08034276a6ccfc986e261ae/PowerShell/PowerShell/issues/9889
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/571155c07b73226aa99f8e91b6356c0d2b547ac4b08034276a6ccfc986e261ae/PowerShell/PowerShell/issues/9889
og:image:altPSScriptAnalyzer version of 1.18.0 or older sporadically encounter an exception when calling Test-ModuleManifest concurrently, it seems to be an issue of the PowerShell engine code itself, not the ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebergmeister
hostnamegithub.com
expected-hostnamegithub.com
None99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseecfd63ca125ec74b42f74eeb158b3fa081c8c497
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/9889#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F9889
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F9889
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/9889
Reloadhttps://github.com/PowerShell/PowerShell/issues/9889
Reloadhttps://github.com/PowerShell/PowerShell/issues/9889
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests364 (364)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/9889
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/9889
Test-ModuleManifest is not thread safe (exceptions thrown from deep inside PowerShell engine)https://github.com/PowerShell/PowerShell/issues/9889#top
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
https://github.com/bergmeister
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Jun 13, 2019https://github.com/PowerShell/PowerShell/issues/9889#issue-455872725
https://github.com/PowerShell/PSScriptAnalyzer/blob/0bef1c8b8ddf5b570dd0b6c90f0d0257b94eb374/Engine/Helper.cs#L306-L315https://github.com/PowerShell/PSScriptAnalyzer/blob/0bef1c8b8ddf5b570dd0b6c90f0d0257b94eb374/Engine/Helper.cs#L306-L315
https://github.com/PowerShell/PSScriptAnalyzer/blob/a68b13956ab1136af91066d1ce61113574447945/Engine/ScriptAnalyzer.cs#L2075https://github.com/PowerShell/PSScriptAnalyzer/blob/a68b13956ab1136af91066d1ce61113574447945/Engine/ScriptAnalyzer.cs#L2075
repro.ziphttps://github.com/PowerShell/PowerShell/files/3287403/repro.zip
#9860https://github.com/PowerShell/PowerShell/pull/9860
herehttps://www.dropbox.com/s/pgblge4chymc8wc/pwsh.dmp?dl=0
pipelinebase.cs (line 416) https://github.com/PowerShell/PowerShell/blob/d80154430d600a52a1d1e3a9f3ecf032b36185d4/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs#L416
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
on Jun 13, 2019https://github.com/PowerShell/PowerShell/issues/9889#event-2411424888
Ilya (iSazonov)https://github.com/iSazonov
Area-Cmdlets-Corehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Area-Cmdlets-Core%22
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
on Jun 14, 2019https://github.com/PowerShell/PowerShell/issues/9889#event-2412532097
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/9889#issuecomment-1813815349
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/9889#issuecomment-1813815352
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/9889#issuecomment-1813815353
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/9889#event-10975857180
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 23, 2023https://github.com/PowerShell/PowerShell/issues/9889#issuecomment-1824370349
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 23, 2023https://github.com/PowerShell/PowerShell/issues/9889#event-11047277879
Ryan Yates (kilasuit)https://github.com/kilasuit
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
WG-Cmdlets-Corehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets-Core%22
on Jul 17, 2026https://github.com/PowerShell/PowerShell/issues/9889#event-28145149075
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/9889
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/9889
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.