Skip to content

Compiling application with LanguageExt as a dependency and ReadyToRun enabled using .NET 6 #66079

Description

@AndreSteenveld

Description

When compiling an application with .NET 5 and ReadyToRun enabled a binary is produced, trying to do the same with .NET 6 just "hangs". If a publish profile is used and -p:PublishReadyToRunCrossgen2ExtraArgs='--verbose' is provided it looks like crossgen2 is really busy processing all possible combinations of all possible generic classes. (That is more speculation from my side than anything else though)

Reproduction Steps

I've built a small application which can be found here; AndreSteenveld.CrossgenLanguageExt. Summarizing the readme; Running dotnet publish ./AndreSteenveld.CrossgenLanguageExt5.csproj -p:PublishSingleFile=true -p:PublishReadyToRun=true --configuration Release --runtime win-x64 --self-contained true produces a binary as expected. But doing the same for a .NET 6 project doesn't.

Expected behavior

I'm not expecting any super fast compilation, but nevertheless I do expect it to finish some time.

Actual behavior

Compile doesn't finish, even after several hours.

Regression?

I've read in the release notes that crossgen2 was released with .NET 6, so I'm assuming there is another (older) version of crossgen for .NET 5. So that would be my first suspect.

Known Workarounds

No response

Configuration

Running dotnet --info outputs the following:

.NET SDK (reflecting any global.json):
 Version:   6.0.102
 Commit:    02d5242ed7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.102\

Host (useful for support):
  Version: 6.0.2
  Commit:  839cdfb0ec

.NET SDKs installed:
  3.1.416 [C:\Program Files\dotnet\sdk]
  5.0.211 [C:\Program Files\dotnet\sdk]
  5.0.404 [C:\Program Files\dotnet\sdk]
  5.0.405 [C:\Program Files\dotnet\sdk]
  6.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

My compile target is also windows, x86-64. I do want to try to reproduce this on linux if possible, although I'm not expecting that it does compile (within a reasonable timeframe) on linux either.

Other information

As this is an issue which seems related to LanguageExt.Core I've also opened a ticket over there. louthy/language-ext#1000 If there is anything else I can do to help please feel free to reach out :)

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Mar 2, 2022
  2. BrunoJuchli commented on Mar 14, 2022

    @BrunoJuchli
    Contributor

    I ran into the same or at least a similar issue today.
    I have an azure-function app (functions v4) where I use LanguageExt.
    I ran the following command from a win-x64 machine:

    dotnet publish --configuration Release --runtime linux-x64 --no-self-contained -p:PublishReadyToRun=true
    

    After waiting for 3hours for compilation of my (rather simple) functions project to end I was presented with the following error message. Note that while I waited the memory usage crew continuously. Crossgen2 always used at least 1 CPU core to a 100%. I didn't check earlier, but after about 2 hours the disk usage also was consistently at about 60-80% (at that time memory usage was at 22Gib and there basically wasn't any memory left, so I assume disk usage might have been caused by swapping).

    Also I tried running this via github action on ubuntu-linux, but I stopped it after 1.5 hours.

    ....\Microsoft.NET.CrossGen.targets(463,5): error : Error: One or more errors occurred. (Code generation failed for method '[LanguageExt.Core]LanguageExt.TypeClass.biIterAsync<MOptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,OptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>,Unit>(OptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Action`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Action`1)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Either`2<LanguageExt.EitherUnsafe`2<System.__Canon,System.__Canon>,LanguageExt.Unit>>>>>>>>.Concat(IReadOnlyCollection`1<Seq`1<Seq`1<Seq`1<Seq`1<Seq`1<Seq`1<Either`2<EitherUnsafe`2<__Canon,__Canon>,Unit>>>>>>>>)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.SetInternal`2<LanguageExt.ClassInstances.OrdDefault`1<LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.EitherUnsafe`2<LanguageExt.Common.Error,float32>>>,LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.EitherUnsafe`2<LanguageExt.Common.Error,float32>>>.Skip(int32)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Either`2<LanguageExt.Either`2<LanguageExt.Seq`1<LanguageExt.Seq`1>,LanguageExt.Common.Error>,LanguageExt.Common.Error>.Right(Action`1)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Choice.rightAsEnumerable<MEither`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>,Either`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>,Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>(Either`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Pool`2<LanguageExt.ListEnumerator`1+NewStack<LanguageExt.Either`2<LanguageExt.Seq`1<LanguageExt.Common.Error>,LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.Unit>>>,System.__Canon>..cctor()') [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : System.AggregateException: One or more errors occurred. (Code generation failed for method '[LanguageExt.Core]LanguageExt.TypeClass.biIterAsync<MOptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,OptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>,Unit>(OptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Action`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Action`1)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Either`2<LanguageExt.EitherUnsafe`2<System.__Canon,System.__Canon>,LanguageExt.Unit>>>>>>>>.Concat(IReadOnlyCollection`1<Seq`1<Seq`1<Seq`1<Seq`1<Seq`1<Seq`1<Either`2<EitherUnsafe`2<__Canon,__Canon>,Unit>>>>>>>>)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.SetInternal`2<LanguageExt.ClassInstances.OrdDefault`1<LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.EitherUnsafe`2<LanguageExt.Common.Error,float32>>>,LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.EitherUnsafe`2<LanguageExt.Common.Error,float32>>>.Skip(int32)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Either`2<LanguageExt.Either`2<LanguageExt.Seq`1<LanguageExt.Seq`1>,LanguageExt.Common.Error>,LanguageExt.Common.Error>.Right(Action`1)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Choice.rightAsEnumerable<MEither`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>,Either`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>,Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>(Either`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>)') (Code generation failed for method '[LanguageExt.Core]LanguageExt.Pool`2<LanguageExt.ListEnumerator`1+NewStack<LanguageExt.Either`2<LanguageExt.Seq`1<LanguageExt.Common.Error>,LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.Unit>>>,System.__Canon>..cctor()') [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> ILCompiler.CodeGenerationFailedException: Code generation failed for method '[LanguageExt.Core]LanguageExt.TypeClass.biIterAsync<MOptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,OptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>,Unit>(OptionAsync`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Action`1<Seq`1<Seq`1<Either`2<Aff`1<__Canon>,__Canon>>>>,Action`1)' [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> System.OverflowException: Arithmetic operation resulted in an overflow. [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.Expand(TValue[] oldHashtable) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.AddOrGetExistingInner(TValue value, Boolean& addedValue) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey key) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.MethodDesc.InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.IL.InstantiatedMethodIL.GetObject(Int32 token, NotFoundBehavior notFoundBehavior) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.ResolveTokenInScope(MethodILScope methodIL, Object typeOrMethodContext, mdToken token) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.resolveToken(CORINFO_RESOLVED_TOKEN& pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl._resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of inner exception stack trace --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo methodCodeNodeNeedingCode, Logger logger) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.b__36_0(DependencyNodeCore`1 dependency) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of stack trace from previous location --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.TaskReplicator.Replica.Execute() [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of inner exception stack trace --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of stack trace from previous location --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IList`1 list, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.ComputeDependencyNodeDependencies(List`1 obj) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.Compile(String outputFile) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.Program.RunSingleCompilation(Dictionary`2 inFilePaths, InstructionSetSupport instructionSetSupport, String compositeRootPath, Dictionary`2 unrootedInputFilePaths, HashSet`1 versionBubbleModulesHash, CompilerTypeSystemContext typeSystemContext) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.Program.Run(String[] args) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.Program.Main(String[] args) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> (Inner Exception #1) ILCompiler.CodeGenerationFailedException: Code generation failed for method '[LanguageExt.Core]LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Seq`1<LanguageExt.Either`2<LanguageExt.EitherUnsafe`2<System.__Canon,System.__Canon>,LanguageExt.Unit>>>>>>>>.Concat(IReadOnlyCollection`1<Seq`1<Seq`1<Seq`1<Seq`1<Seq`1<Seq`1<Either`2<EitherUnsafe`2<__Canon,__Canon>,Unit>>>>>>>>)' [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> System.OverflowException: Arithmetic operation resulted in an overflow. [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.Expand(TValue[] oldHashtable) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.AddOrGetExistingInner(TValue value, Boolean& addedValue) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey key) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.MethodDesc.InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.IL.InstantiatedMethodIL.GetObject(Int32 token, NotFoundBehavior notFoundBehavior) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.ResolveTokenInScope(MethodILScope methodIL, Object typeOrMethodContext, mdToken token) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.resolveToken(CORINFO_RESOLVED_TOKEN& pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl._resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of inner exception stack trace --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo methodCodeNodeNeedingCode, Logger logger) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.b__36_0(DependencyNodeCore`1 dependency) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of stack trace from previous location --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.TaskReplicator.Replica.Execute()<--- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> (Inner Exception #2) ILCompiler.CodeGenerationFailedException: Code generation failed for method '[LanguageExt.Core]LanguageExt.SetInternal`2<LanguageExt.ClassInstances.OrdDefault`1<LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.EitherUnsafe`2<LanguageExt.Common.Error,float32>>>,LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.EitherUnsafe`2<LanguageExt.Common.Error,float32>>>.Skip(int32)' [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> System.OverflowException: Arithmetic operation resulted in an overflow. [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.Expand(TValue[] oldHashtable) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.AddOrGetExistingInner(TValue value, Boolean& addedValue) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey key) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.MethodDesc.InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.IL.InstantiatedMethodIL.GetObject(Int32 token, NotFoundBehavior notFoundBehavior) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.ResolveTokenInScope(MethodILScope methodIL, Object typeOrMethodContext, mdToken token) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.resolveToken(CORINFO_RESOLVED_TOKEN& pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl._resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of inner exception stack trace --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo methodCodeNodeNeedingCode, Logger logger) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.b__36_0(DependencyNodeCore`1 dependency) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of stack trace from previous location --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.TaskReplicator.Replica.Execute()<--- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> (Inner Exception #3) ILCompiler.CodeGenerationFailedException: Code generation failed for method '[LanguageExt.Core]LanguageExt.Either`2<LanguageExt.Either`2<LanguageExt.Seq`1<LanguageExt.Seq`1>,LanguageExt.Common.Error>,LanguageExt.Common.Error>.Right(Action`1)' [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> System.OverflowException: Arithmetic operation resulted in an overflow. [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.Expand(TValue[] oldHashtable) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.AddOrGetExistingInner(TValue value, Boolean& addedValue) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey key) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.MethodDesc.InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.IL.InstantiatedMethodIL.GetObject(Int32 token, NotFoundBehavior notFoundBehavior) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.ResolveTokenInScope(MethodILScope methodIL, Object typeOrMethodContext, mdToken token) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.resolveToken(CORINFO_RESOLVED_TOKEN& pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl._resolveToken(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of inner exception stack trace --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo methodCodeNodeNeedingCode, Logger logger) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.b__36_0(DependencyNodeCore`1 dependency) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of stack trace from previous location --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.TaskReplicator.Replica.Execute()<--- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> (Inner Exception #4) ILCompiler.CodeGenerationFailedException: Code generation failed for method '[LanguageExt.Core]LanguageExt.Choice.rightAsEnumerable<MEither`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>,Either`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>,Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>(Either`2<Fin`1<Identity`1<__Canon>>,Seq`1<Seq`1<Seq`1>>>)' [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> System.OverflowException: Arithmetic operation resulted in an overflow. [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.Expand(TValue[] oldHashtable) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.AddOrGetExistingInner(TValue value, Boolean& addedValue) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey key) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.MethodDesc.InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.ResolveTokenWithSubstitution(MethodILScope methodIL, mdToken token, Instantiation typeInst, Instantiation methodInst) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.GetRuntimeDeterminedObjectForToken(CORINFO_RESOLVED_TOKEN& pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.getReadyToRunHelper(CORINFO_RESOLVED_TOKEN& pResolvedToken, CORINFO_LOOKUP_KIND& pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP& pLookup) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl._getReadyToRunHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP_KIND* pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP* pLookup) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of inner exception stack trace --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo methodCodeNodeNeedingCode, Logger logger) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.b__36_0(DependencyNodeCore`1 dependency) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of stack trace from previous location --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.TaskReplicator.Replica.Execute()<--- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> (Inner Exception #5) ILCompiler.CodeGenerationFailedException: Code generation failed for method '[LanguageExt.Core]LanguageExt.Pool`2<LanguageExt.ListEnumerator`1+NewStack<LanguageExt.Either`2<LanguageExt.Seq`1<LanguageExt.Common.Error>,LanguageExt.Either`2<LanguageExt.Common.Error,LanguageExt.Unit>>>,System.__Canon>..cctor()' [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : ---> System.OverflowException: Arithmetic operation resulted in an overflow. [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.Expand(TValue[] oldHashtable) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.AddOrGetExistingInner(TValue value, Boolean& addedValue) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey key) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.TypeSystem.MethodDesc.GetSharedRuntimeFormMethodTarget() [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.GetRuntimeDeterminedObjectForToken(CORINFO_RESOLVED_TOKEN& pResolvedToken) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.getReadyToRunHelper(CORINFO_RESOLVED_TOKEN& pResolvedToken, CORINFO_LOOKUP_KIND& pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP& pLookup) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl._getReadyToRunHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP_KIND* pGenericLookupKind, CorInfoHelpFunc id, CORINFO_CONST_LOOKUP* pLookup) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of inner exception stack trace --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo methodCodeNodeNeedingCode, Logger logger) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at ILCompiler.ReadyToRunCodegenCompilation.b__36_0(DependencyNodeCore`1 dependency) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : --- End of stack trace from previous location --- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : at System.Threading.Tasks.TaskReplicator.Replica.Execute()<--- [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(463,5): error : [<..ProjectDir..>\Functions.csproj]
    ....\Microsoft.NET.CrossGen.targets(351,5): error NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the PublishReadyToRun property to false. [<..ProjectDir..>\Functions.csproj]

    Note: '....\Microsoft.NET.CrossGen.targets' originally was 'C:\Program Files\dotnet\sdk\6.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets'

  3. BrunoJuchli commented on Mar 14, 2022

    @BrunoJuchli
    Contributor

    As recommended by the NETSDK1096 error I tried disabling optimization for LanguageExt.Core.dll by adding the following to the *.csproj:

    <ItemGroup>
      <PublishReadyToRunExclude Include="LanguageExt.Core.dll" />
    </ItemGroup>
    

    As a result, the build now seems to hang indefinitely. Crossgen2 is not running, cpu is idle, memory usage remains low.
    This is how the console looks:
    image

    Using Ctrl+C to cancel results in the following:

    Microsoft.NET.Sdk.Functions.Publish.targets(148,5): warning MSB4220: Waiting for the currently executing task "GenerateFunctions" to cancel.
    

    Which just gets repeated, for ever.
    Also, I've tried rebooting, then performing dotnet clean followed by publish again. Same result.

  4. AndreSteenveld commented on Mar 22, 2022

    @AndreSteenveld
    Author

    Trimming LanguageExt allows it to build to native, which seems like a perfectly fine workaround. I've read in the .NET7 beta release notes that it is an essential step for compiling to native so I guess it's fine. I still don't know the root cause though.

    I've updated my reproduction case, in summary:

    <!-- I've added this section to the `AndreSteenveld.CrossgrenLangueageExt6.csproj` file, it was taken from: https://github.com/louthy/language-ext/issues/673#issuecomment-778358899 -->
    <Target Name="ConfigureTrimming" BeforeTargets="PrepareForILLink">
      <ItemGroup>
        <ManagedAssemblyToLink Condition="'%(Filename)' == 'LanguageExt.Core'">
          <IsTrimmable>true</IsTrimmable>
          <TrimMode>link</TrimMode>
        </ManagedAssemblyToLink>
      </ItemGroup>
    </Target>
    $ time dotnet publish ./AndreSteenveld.CrossgenLanguageExt6.csproj  \
        --configuration Release                                         \
        --runtime win-x64                                               \
        --self-contained true                                           \
        -p:PublishSingleFile=true                                       \
        -p:PublishReadyToRun=true                                       \
        -p:PublishReadyToRunShowWarnings=true                           \
        -p:PublishTrimmed=true
    Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
    Copyright (C) Microsoft Corporation. All rights reserved.
    
      Determining projects to restore...
      Restored C:\Users\asteenveld\source\repos\AndreSteenveld.CrossgenLanguageExt\AndreSteenveld.CrossgenLanguageExt6.csproj (in 15.47 sec).
      AndreSteenveld.CrossgenLanguageExt6 -> C:\Users\asteenveld\source\repos\AndreSteenveld.CrossgenLanguageExt\bin\Release\net6.0\win-x64\AndreSteenveld.CrossgenLanguageExt6.dll 
        C:\Users\asteenveld\.nuget\packages\languageext.core\4.0.3\lib\netstandard2.0\LanguageExt.Core.dll : warning IL2104: Assembly 'LanguageExt.Core' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\Users\asteenveld\source\repos\AndreSteenveld.CrossgenLanguageExt\AndreSteenveld.CrossgenLanguageExt6.csproj]
      Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
      AndreSteenveld.CrossgenLanguageExt6 -> C:\Users\asteenveld\source\repos\AndreSteenveld.CrossgenLanguageExt\bin\Release\net6.0\win-x64\publish\
    
    real   	1m35.580s
    user   	0m0.000s
    sys    	0m0.093s
  5. normj commented on May 5, 2022

    @normj

    While debugging this issue for somebody trying to run this package with ReadyToRun on AWS I noticed that when you can get the crossgen2 compiler to complete it turns the 11 Meg LanguageExt.Core.dll into a 270+ Meg dll.

    This library uses a lot of generics and Reflection.Emit over generic types. I wonder if the crossgen2 is getting into some overaggressive mode trying to generate ReadyToRun code for all of the possible types.

  6. removed
    untriagedNew issue has not been triaged by the area owner
    on May 6, 2022
  7. added this to the 7.0.0 milestone on May 6, 2022
  8. trylek commented on May 6, 2022

    @trylek
    Member

    I have managed to repro this locally. The problem is indeed caused by generic explosion, the proximate bug the debug compiler build hits is an integer overflow when resizing the generic unification hashtable. As the next experimental step I'm thinking about introducing a heuristic "generic complexity" and using it to trim too complex instantiations; I'm also looking into ways to somehow record the increasing generic complexity as part of the dependency analysis as a tool for understanding what triggers the infinite instantiation loop.

  9. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 29, 2022
  10. 10 remaining items

  11. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 13, 2023
  12. trylek commented on Jun 13, 2023

    @trylek
    Member

    FYI, I have merged in Crossgen2 support for handling this situation cleanly. One caveat is that for now we decided to make the new switch an opt-in because this issue is the first one we discovered hitting this problem and the implementation makes the compilation slower. It should ship as part of .NET 8 Preview 6 and it would be naturally great if @AndreSteenveld and / or some of the other contributors to this thread could verify that it fixes their issues. The relevant option that needs to be put in the project file is as follows:

    <PublishReadyToRunCrossgen2ExtraArgs>--enable-generic-cycle-detection</PublishReadyToRunCrossgen2ExtraArgs>
    

    Thanks in advance!

    P.S. The change implements two additional switches that control the internal heuristic, maxgenericcycle and maxgenericcyclebreadth but these shouldn't be needed for compiling LanguageExt.Core.

  13. ghost locked as resolved and limited conversation to collaborators on Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions