Attempting to port PowerShell Core 6 to .Net Core 3.0 as part of https://github.com/PowerShell/PowerShell/pull/8370. Some assemblies get crossgen'd, but crossgen fails on System.Management.Automation.dll with exit code 139. Using /verbose there is no additional information indicating the non-zero error code. Seems to be succeeding on Windows, but fails on macOS and Linux. Using 3.0.100-preview-010184
@janvorli, could you please try to reproduce the failure on Linux and do initial triage?
Sure, I'll take a look. @SteveL-MSFT can I repro it just by getting the https://github.com/PowerShell/PowerShell/pull/8370 and building it?
@janvorli yes, just use start-psbuild -crossgen on macOS or Linux.
@SteveL-MSFT it seem I have problem doing the build correctly. This is what I get as a response to the command above. Any idea what might be wrong?
start-psbuild -crossgen
VERBOSE: Using configuration 'Debug'
VERBOSE: Top project directory is /home/janvorli/git/powershell/src/powershell-unix
VERBOSE: Using framework 'netcoreapp3.0'
VERBOSE: Using runtime 'linux-x64'
Run dotnet publish --no-restore /property:GenerateFullPaths=true --configuration Debug --framework netcoreapp3.0 --runtime linux-x64 from /home/janvorli/git/powershell/src/powershell-unix
Microsoft (R) Build Engine version 16.0.385-preview+g966cdf2ac6 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Microsoft.PowerShell.CoreCLR.Eventing -> /home/janvorli/git/powershell/src/Microsoft.PowerShell.CoreCLR.Eventing/bin/Debug/netcoreapp3.0/Microsoft.PowerShell.CoreCLR.Eventing.dll
System.Management.Automation -> /home/janvorli/git/powershell/src/System.Management.Automation/bin/Debug/netcoreapp3.0/System.Management.Automation.dll
Microsoft.PowerShell.MarkdownRender -> /home/janvorli/git/powershell/src/Microsoft.PowerShell.MarkdownRender/bin/Debug/netcoreapp3.0/Microsoft.PowerShell.MarkdownRender.dll
Microsoft.PowerShell.Security -> /home/janvorli/git/powershell/src/Microsoft.PowerShell.Security/bin/Debug/netcoreapp3.0/Microsoft.PowerShell.Security.dll
Microsoft.PowerShell.ConsoleHost -> /home/janvorli/git/powershell/src/Microsoft.PowerShell.ConsoleHost/bin/Debug/netcoreapp3.0/Microsoft.PowerShell.ConsoleHost.dll
Microsoft.PowerShell.Commands.Management -> /home/janvorli/git/powershell/src/Microsoft.PowerShell.Commands.Management/bin/Debug/netcoreapp3.0/Microsoft.PowerShell.Commands.Management.dll
Microsoft.PowerShell.Commands.Utility -> /home/janvorli/git/powershell/src/Microsoft.PowerShell.Commands.Utility/bin/Debug/netcoreapp3.0/Microsoft.PowerShell.Commands.Utility.dll
Microsoft.PowerShell.SDK -> /home/janvorli/git/powershell/src/Microsoft.PowerShell.SDK/bin/Debug/netcoreapp3.0/Microsoft.PowerShell.SDK.dll
powershell-unix -> /home/janvorli/git/powershell/src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/pwsh.dll
powershell-unix -> /home/janvorli/git/powershell/src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish/
VERBOSE: Matched CrossGen.exe: /home/janvorli/.nuget/packages/symbolpackages/runtime.linux-x64.Microsoft.NETCore.Runtime.CoreCLR.3.0.0-preview-27316-72/tools/crossgen
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
xdg-open: unexpected argument '/MissingDependenciesOK'
Try 'xdg-open --help' for more information.
VERBOSE: PowerShell Ngen assemblies have been generated. Deploying ...
Rename-Item : Cannot rename because item at '/home/janvorli/git/powershell/src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish/Microsoft.CodeAnalysis.CSharp.ni.dll' does not exist.
At /home/janvorli/git/powershell/build.psm1:2207 char:9
+ Rename-Item $niAssemblyPath $assemblyPath -Force -ErrorAction ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Rename-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand
Here are the steps I did:
@janvorli can you post output of $PSVersionTable so I know what version of PSCore6 you got installed? What OS are you running this one?
I am running on Ubuntu 16.04.5
Name Value
---- -----
PSVersion 6.1.1
PSEdition Core
GitCommitId 6.1.1
OS Linux 4.4.0-124-generic dotnet/runtime#3927-Ubuntu SMP Wed May 2 13:00:18 UTC 2018
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@janvorli I just installed Ubuntu 16.04 in an image and the error you're getting doesn't repro. Can you try: sudo apt install powershell which should get you to 6.1.2 and see if it repros? The error you are seeing is .Net Core's ShellExecute not properly handling arguments passed to xdg-open (which I believe has since been fixed), but ShellExecute shouldn't be used here when starting crossgen anyways...
I've found that I have not run the ./tools/install-powershell.sh before as root. I've retried and now the $PSVersionTable returns the 6.1.2.
However, the issue persists. I am going to try on a VM to see I get lucky there.
Ok, I can repro the original issue on my VM.
Here is the stack trace of the crash, I've just executed the following command line that I've printed out in the powershell script:
/home/janvorli/.nuget/packages/runtime.linux-x64.microsoft.netcore.app/3.0.0-preview-27324-5/tools/crossgen /MissingDependenciesOK /in /home/janvorli/git/PowerShell/src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish/System.Management.Automation.dll /out /home/janvorli/git/PowerShell/src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish/System.Management.Automation.ni.dll /Platform_Assemblies_Paths /home/janvorli/git/PowerShell/src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish
(lldb) bt
* thread dotnet/coreclr#1, name = 'crossgen', stop reason = signal SIGSEGV: invalid address (fault address: 0xc)
* frame #0: 0x00007ffff61f56c7 libclrjit.so`CodeGen::genStructPutArgUnroll(GenTreePutArgStk*) + 55
frame dotnet/coreclr#1: 0x00007ffff61eeb5d libclrjit.so`CodeGen::genCodeForTreeNode(GenTree*) + 21853
frame dotnet/coreclr#2: 0x00007ffff60a75f3 libclrjit.so`CodeGen::genGenerateCode(void**, unsigned int*) + 14915
frame dotnet/coreclr#3: 0x00007ffff60c89f1 libclrjit.so`Compiler::compCompile(void**, unsigned int*, JitFlags*) + 52625
frame dotnet/coreclr#4: 0x00007ffff60d2fec libclrjit.so`Compiler::compCompile(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*) + 7580
frame dotnet/coreclr#5: 0x00007ffff60d56c1 libclrjit.so`jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*) + 2465
frame dotnet/coreclr#6: 0x00007ffff60d6dc3 libclrjit.so`CILJit::compileMethod(ICorJitInfo*, CORINFO_METHOD_INFO*, unsigned int, unsigned char**, unsigned int*) + 131
frame dotnet/coreclr#7: 0x0000000000686b40 crossgen`ZapInfo::CompileMethod() + 560
frame dotnet/coreclr#8: 0x000000000067faab crossgen`ZapImage::TryCompileMethodWorker(CORINFO_METHOD_STRUCT_*, unsigned int, unsigned int) + 667
frame dotnet/coreclr#9: 0x000000000067e767 crossgen`ZapImage::TryCompileMethodDef(unsigned int, unsigned int) + 199
frame dotnet/coreclr#10: 0x000000000067ef36 crossgen`ZapImage::CompileColdRegion() + 166
frame dotnet/coreclr#11: 0x000000000067f137 crossgen`ZapImage::Compile() + 23
frame dotnet/coreclr#12: 0x00000000006791b5 crossgen`Zapper::CompileModule(CORINFO_MODULE_STRUCT_*, IMetaDataAssemblyEmit*) + 197
frame dotnet/coreclr#13: 0x000000000067813c crossgen`Zapper::CompileAssembly(_GUID*) + 684
frame dotnet/coreclr#14: 0x00000000006751b6 crossgen`Zapper::Compile(char16_t const*, _GUID*) + 198
frame dotnet/coreclr#15: 0x0000000000674eae crossgen`NGenWorker + 510
frame dotnet/coreclr#16: 0x00000000004ebb7d crossgen`wmain(int, char16_t**) + 3469
frame dotnet/coreclr#17: 0x00000000004ec08e crossgen`main + 206
frame dotnet/coreclr#18: 0x00007ffff6b63830 libc.so.6`__libc_start_main(main=(crossgen`main), argc=8, argv=0x00007fffffffe218, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe208) at libc-start.c:291
frame dotnet/coreclr#19: 0x00000000004e9cc3 crossgen`_start + 41
So it crashes in JIT. @dotnet/jit-contrib can someone take a look at this?
Taking an initial look.
Seem to have found an assert running in debug.
```
Assert failure(PID 17211 [0x0000433b], Thread: 67491 [0x107a3]): Assertion failed 'arg->TypeGet() != TYP_STRUCT' in 'Microsoft.PowerShell.Commands.ModuleCmdletBase:LoadModule(ref,ref,ref,ref,ref,ref,byref,int,byref,byref):ref:this' (IL size 2918)
File: /Users/jashoo/projects/coreclr/src/jit/lower.cpp Line: 1191
Image: /Users/jashoo/projects/coreclr/bin/tests/OSX.x64.Debug/Tests/Core_Root/crossgen
````
For anyone looking to repro my steps were:
Note on OSX
git clone [email protected]:bergmeister/PowerShell -b release3.0
cd PowerShell
./tools/install-powershell.sh
pwsh
Start-PSBootstrap
Start-PSBuild
git clone [email protected]:dotnet/coreclr
./build.sh && ./build-test.sh generatelayoutonly
export CORE_ROOT=/Users/jashoo/projects/coreclr/bin/tests/OSX.x64.Debug/Tests/Core_Root
$CORE_ROOT/crossgen /verbose /MissingDependenciesOK /in /Users/jashoo/projects/PowerShell/src/powershell-unix/bin/Debug/netcoreapp3.0/osx-x64/publish/System.Management.Automation.dll /out /Users/jashoo/projects/PowerShell/src/powershell-unix/bin/Debug/netcoreapp3.0/osx-x64/publish/System.Management.Automation.ni.dll /Platform_Assemblies_Paths /Users/jashoo/projects/PowerShell/src/powershell-unix/bin/Debug/netcoreapp3.0/osx-x64/publish/
The problem has been found, dotnet/coreclr#22437 has been opened to address the issue. I have verified I can complete the crossgen successfully with the fix.
Change has been merged into master. Working on getting a CoreCLR official build.