$context = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext([System.Reflection.Assembly]::GetExecutingAssembly())
PowerShell or .NET Core handles the error gracefully, or perhaps the API call succeeds, if it's supposed to.
[1] 40918 segmentation fault powershell
Name Value
---- -----
PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.18
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Cheers,
Trevor Sullivan
[1] 40918 segmentation fault powershell
@daxian-dbw Could you please comment the Issue?
Ah, another AssemblyLoadContext bug. It doesn't work well with dynamic assemblies that are emitted on the fly. I believe it's related to https://github.com/dotnet/corefx/issues/18877
See the below C# repro
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.Loader;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
AssemblyName aName = new AssemblyName("Microsoft.PowerShell.Cmdletization.GeneratedTypes");
AssemblyBuilder ab = AssemblyBuilder.DefineDynamicAssembly(aName, AssemblyBuilderAccess.Run);
ModuleBuilder mb = ab.DefineDynamicModule(aName.Name);
string fullEnumName = "Microsoft.PowerShell.Cmdletization.GeneratedTypes.TestEnum";
Type underlyingType = typeof(Int32);
EnumBuilder eb = mb.DefineEnum(fullEnumName, TypeAttributes.Public, underlyingType);
eb.DefineLiteral("Single", 0);
eb.DefineLiteral("Multiple", 1);
TypeInfo ti = eb.CreateTypeInfo();
Console.WriteLine("Dynamic assembly emitted: {0}", ti.Assembly.FullName);
var loadContext = AssemblyLoadContext.GetLoadContext(ti.Assembly);
Console.WriteLine("Yay"); // Program crashes, so this line never gets printed out
}
}
}
d:\cmdlet\Sample>dotnet run
Dynamic assembly emitted: Microsoft.PowerShell.Cmdletization.GeneratedTypes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
d:\cmdlet\Sample>
I just opened an issue at https://github.com/dotnet/corefx/issues/18989
Issue was moved to here: https://github.com/dotnet/coreclr/issues/11228
I can not repo with Beta.8
Most helpful comment
I just opened an issue at https://github.com/dotnet/corefx/issues/18989