Powershell: [PSRP over SSH] Invoke-Command -ScriptBlock { Get-ChildItem -Path /tmp } locks up session

Created on 18 Aug 2016  路  4Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Create PSSession over SSH to Linux. Doesn't matter if it's initiated from Linux or Windows.

#works fines
Invoke-Command -Session $session -ScriptBlock { ls /tmp }
#locks up session
Invoke-Command -Session $session -ScriptBlock { Get-ChildItem -Path /tmp }

untitled

Expected behavior

Should work.

Actual behavior

Locks up.

Environment data

Linux node is CentOS 72 1511
Windows node is Windows 10 AU 1607
versiontable

Issue-Bug OS-Linux Resolution-External WG-Engine

All 4 comments

This is an interesting bug. It is not an error in PowerShell remoting or the serialization layer, or even in PowerShell. The bug looks to be in the CLR. This hang only occurs on Linux when enumerating named pipe files (e.g., /tmp/clr-debug-pipe-12555-7925167-in).

When enumerating files in a directory PowerShell returns System.IO.FileSystemInfo objects. These objects include custom members, and one (VersionInfo) that returns a System.Diagnostics.FileVersionInfo object via a PowerShell script.

[System.Diagnostics.FileVersionInfo]::GetVersionInfo('/tmp/clr-debug-pipe-12555-7925167-in')

This causes the process to hang and happens whenever the static method is called with a named pipe file path. No exception is thrown, just the process/thread hangs.

The reason this hangs PowerShell remoting is that when the FileInfo object is serialized the VersionInfo custom property needs to be evaluated by running the above script. The hang also occurs if you try to serialize a FileInfo object corresponding to a named pipe file.

dir /tmp/clr-debug-pipe-12555-7925167-in | Export-CliXml -Path $home/FI.xml
````
One workaround is to return strings instead of de-serialized objects

```powershell
Invoke-Command -Session $s -Script { Get-ChildItem /tmp | Out-String }

Since this is a very specific case I feel it is not a beta-1 bug and am moving it to beta-2 time frame.

This will need to be investigated by the CLR team since it does not appear to be related to PowerShell.

@PaulHigin please open a bug for dotnet and link it here

Ok, I have created an issue on DotNetCore
https://github.com/dotnet/corefx/issues/18409

This has been fixed by the DotNetCore team.

Was this page helpful?
0 / 5 - 0 ratings