Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deadlock on Interop+Shell32.SHGetKnownFolderPath using -MTA/-STA flag #21506

Open
5 tasks done
MaxClaessen opened this issue Apr 19, 2024 · 1 comment
Open
5 tasks done
Labels
Needs-Triage The issue is new and needs to be triaged by a work group.

Comments

@MaxClaessen
Copy link

Prerequisites

Steps to reproduce

when running pwsh it gets stuck occasionally on some machines when using the flag(s) -MTA or -STA after investigations it gets stuck on Interop+Shell32.SHGetKnownFolderPath .
This happens even on a script that runs pwsh.exe -MTA -NoProfile -Command "$PSVersionTable.PSVersion.ToString()"
This does not happen on all our developer machines (Running Win 10 22H2), so far we have not been able to pinpoint the difference.

Stacktrace:

0000001A1C57D670 00007ffe4770d064 [InlinedCallFrame: 0000001a1c57d670] 
0000001A1C57D670 00007ffd9bf3e6eb [InlinedCallFrame: 0000001a1c57d670] 
0000001A1C57D640 00007ffd9bf3e6eb Interop+Shell32.SHGetKnownFolderPath(System.Guid ByRef, UInt32, IntPtr, System.String ByRef) [/_/src/coreclr/System.Private.CoreLib/Microsoft.Interop.LibraryImportGenerator/Microsoft.Interop.LibraryImportGenerator/LibraryImports.g.cs @ 8003]
0000001A1C57D740 00007ffd9bf52e19 System.Environment.GetFolderPathCore(SpecialFolder, SpecialFolderOption) [/_/src/libraries/System.Private.CoreLib/src/System/Environment.Win32.cs @ 375]
0000001A1C57D790 00007ffd9bf51f0b System.Environment.GetFolderPath(SpecialFolder, SpecialFolderOption) [/_/src/libraries/System.Private.CoreLib/src/System/Environment.cs @ 134]
0000001A1C57D7E0 00007ffd9ab23d4e System.Management.Automation.Platform..cctor()
0000001A1C57E990 00007ffd9cb0a333 [DynamicHelperFrame: 0000001a1c57e990] 
0000001A1C57EAF0 00007ffd9ab239ab System.Management.Automation.Platform.get_IsWindowsDesktop()
0000001A1C57EB20 00007ffd9baf9427 Microsoft.PowerShell.CommandLineParameterParser.ParseHelper(System.String[])
0000001A1C57EBB0 00007ffd9baff604 Microsoft.PowerShell.ConsoleHost.ParseCommandLine(System.String[])
0000001A1C57EBF0 00007ffd9bb0dcfd Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
0000001A1C57EC50 00007ffdd7cc0f9d Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])

Expected behavior

powershell should finish execution

Actual behavior

powershell gets stuck in a deadlock

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@MaxClaessen MaxClaessen added the Needs-Triage The issue is new and needs to be triaged by a work group. label Apr 19, 2024
@rhubarb-geek-nz
Copy link

rhubarb-geek-nz commented Apr 19, 2024

Can you try GetFolderPath and enumerate through the SpecialFolder and SpecialFolderOption to see if there is a specific one tripping your users up?

Eg (uses %% because it is in a batch file)

for %%F in (CommonDocuments,CommonProgramFiles) do (
	for %%O in (DoNotVerify,None) do (
		pwsh.exe -c "[System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::%%F,[System.Environment+SpecialFolderOption]::%%O)"
	)
)

For instance is it looking for a network share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Triage The issue is new and needs to be triaged by a work group.
Projects
None yet
Development

No branches or pull requests

2 participants