runtime: PowerShell crash on exit in Windows containers
Description
This is a really strange one. In the latest builds of 6.0 Preview 5, PowerShell 7 will crash on exit after it has run for a certain amount of time. I have attempted to configure the container to collect a crash dump but nothing gets output by WER. I think the underlying issue could be GC-related.
Repro steps
Dockerfile:
# escape=`
FROM mcr.microsoft.com/windows/servercore:20H2
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG DOTNET_SDK_VERSION=6.0.100-preview.5.21275.4
RUN `
# Retrieve .NET SDK
Invoke-WebRequest -OutFile dotnet.zip https://dotnetcli.azureedge.net/dotnet/Sdk/$Env:DOTNET_SDK_VERSION/dotnet-sdk-$Env:DOTNET_SDK_VERSION-win-x64.zip; `
mkdir 'C:\Program Files\dotnet'; `
tar -C 'C:\Program Files\dotnet' -oxzf dotnet.zip; `
Remove-Item -Force dotnet.zip;
RUN `
# Install PowerShell global tool
$powershell_version = '7.2.0-preview.5'; `
Invoke-WebRequest -OutFile PowerShell.Windows.x64.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Windows.x64.$powershell_version.nupkg; `
& 'C:\Program Files\dotnet\dotnet.exe' tool install --add-source . --tool-path 'C:\Program Files\powershell' --version $powershell_version PowerShell.Windows.x64; `
& 'C:\Program Files\dotnet\dotnet.exe' nuget locals all --clear;
RUN setx /M PATH '%PATH%;C:\Program Files\powershell'
- Save the above contents to a file named
Dockerfile
in an empty folder and set that folder as current directory in command line. docker build -t test .
docker run --rm test pwsh -Command "Start-Sleep -s 15"
Result:
Fatal error. Internal CLR error. (0x80131506)
If you set the sleep value in step 3 to 10 seconds instead of 15, there is no crash.
Configuration
Repro requires a Windows 10 machine (version 20H2+) with Docker installed and configured to target Windows containers.
Regression?
YES
~I’m still narrowing down which build this regressed in. But here’s what I know. It works in SDK build 6.0.100-preview.5.21262.1 and fails in build 6.0.100-preview.5.21275.4.~
This regression was introduced in build 6.0.100-preview.5.21264.5. The crash does not occur in the previous build, 6.0.100-preview.5.21264.4.
Other information
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (13 by maintainers)
Ok great, it should be included in preview6!
I can confirm that cherry picking the above mentioned fix into the runtime state used by the repro and using rebuilt runtime fixed the problem.
Thank you @rjmholt.
Here is a stack trace at the crash, it occurs because the MethodTable is NULL.
@mangod9 you should be able to find a pwsh build to repro with here. AFAIK, the repro is essentially to run pwsh for a while and then exit it with
exit