Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

nCrunch fails building code containing languageext's newtype
mstramm
#1 Posted : Monday, November 15, 2021 9:42:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/8/2020(UTC)
Posts: 3
Location: Germany

Hi!
I'm a long time nCrunch user and am very happy with it, but for some reason it fails to build when i use some type I really don't want to do without.
First off, here is the repro:

nCrunch version 4.8.0.3

repro.csproj
Code:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="LanguageExt.Core" Version="4.0.3" />
  </ItemGroup>

</Project>


Class1.cs
Code:

namespace crtp_repro {
    public class Class1 : LanguageExt.NewType<Class1, object> {
        public Class1(object value)
            : base(value) { }
    }
}


Expectation:
nCrunch builds the project, same as visual studio

Actual:
nCrunch fails to build the project, but does not report why.


In the workspace, it seems like the project has built successfully, though.

In trying to reproduce the issue, I extracted the code of NewType into the same namespace as Class1, but when I do that, the project builds successfully.

Note that NewType uses all kinds of tricks under the hood, it is a CRTP, uses LanguageExt's fake typeclass mechanism, etc.

My guess is that this somehow messes with nCrunch.
Unfortunately I am stuck with my version of nCrunch for now, so if there is some workaround beside replicating the library's code locally, that would be great.
Remco
#2 Posted : Monday, November 15, 2021 10:52:06 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

Under NCrunch v4.11 (the latest version), I wasn't able to reproduce this problem using the sample code you've provided.

Could you check whether this happens for you under the latest version on NCrunch? If so, would you mind submitting a bug report via NCrunch? It's possible that we've already fixed this problem or that it may be triggered by a difference in your environment.
mstramm
#3 Posted : Tuesday, November 16, 2021 6:59:21 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/8/2020(UTC)
Posts: 3
Location: Germany

Unfortunately my license permits 4.8 at most and I cannot upgrade as of yet.

Instead I went back and tried out a few other versions:
Console tool 4.8.0.3: everything is fine,
Console tool 4.11: everything is fine

nCrucnh 4.7: same problem
nCrunch 3.31.0.3: fails to build, but reports an exception:

Code:

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
nCrunch.Compiler.NewStaticManipulation.CilTypeHashException: Unable to hash type 'crtp_repro.Class1' due to exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at nCrunch.Compiler.Cil.Types.CilNestedClassTable..ctor(CilModule module, CilTableInfo tableInfo)
   at nCrunch.Compiler.Cil.CilModule..ctor(CilAssembly assembly, CilMetadataRoot metadataRoot, CilPeHeaders peHeaders, CilContext context, DirectoryPath workingDirectory, UInt32 entryPointToken)
   at nCrunch.Compiler.Cil.CilAssembly..ctor(Byte[] , CilContext , DirectoryPath )
   at nCrunch.Compiler.Cil.CilAssembly.Load(FilePath assemblyFile, CilContext context)
   at nCrunch.Compiler.Cil.CilContext.LoadAssembly(FilePath assemblyFilePath)
   at nCrunch.Compiler.Cil.CilContext.LoadAssembly(CilAssemblyReference assemblyReference)
   at nCrunch.Compiler.Cil.AssemblyIdentity.CilAssemblyRefTable.GetAssemblyModuleByRowIndex(UInt32 tableIndex)
   at nCrunch.Compiler.Cil.Types.CilTypeReference.()
   at nCrunch.Compiler.Cil.Types.CilTypeReference.ResolveDefinition()
   at nCrunch.Compiler.Cil.Types.CilTypeDefinition.ResolveBaseType()
   at nCrunch.Compiler.NewStaticManipulation.CilMethodHashGenerator.HashType(FNV64& hash, CilTypeDefinition type)
   at nCrunch.Compiler.NewStaticManipulation.BuiltCilAssembly.ExtractClassMethodData(TestFrameworkDescription[] applicableTestFrameworks, IDictionary`2 codeFileIDsByForegroundFilePath, Boolean storeImpactHashes)
   at nCrunch.Compiler.NewStaticManipulation.BuiltCilAssembly.ExtractClassMethodData(TestFrameworkDescription[] applicableTestFrameworks, IDictionary`2 codeFileIDsByForegroundFilePath, Boolean storeImpactHashes)
   at nCrunch.Compiler.RemoteBuildRunner..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters , FilePath , BuildOutput , DirectoryPath[] , FilePath[] )
   at nCrunch.Compiler.RemoteBuildRunner..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters )


I can only guess that 4.8 has a similar issue, though it seems to be a UI problem or instrumentation problem or caching for the hot paths feature.

It is good to know that you cannot repro it in 4.11, but it does put me a tight spot license wise :\
mstramm
#4 Posted : Tuesday, November 16, 2021 7:17:17 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/8/2020(UTC)
Posts: 3
Location: Germany

Alright,
I could use the evaluation license with VS2022, in which I had not yet registered my actual license and can confirm that the bug is fixed starting with nCrunch 4.10, (same with 4.11, in 4.9 for some reason the project fails to load entirely. unfortunately there is no VS2022 build of 4.8).

It is both good and bad that I need a license upgrade to fix the issue, but at least there is a way to fix it.
Thanks for the quick response!
Vincent
#5 Posted : Monday, November 22, 2021 2:49:48 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/1/2017(UTC)
Posts: 7
Location: France

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Using Visual Studio 2019 and Ncrunch 4.11.0.2, I have the same issue (not sure it's the same cause):

[PID:21844 15:45:30.7343 LocalBuildTask-56] ERROR (Internal): System.IndexOutOfRangeException: L'index se trouve en dehors des limites du tableau.
à nCrunch.Compiler.Cil.Types.CilNestedClassTable..ctor(CilModule module, CilTableInfo tableInfo)
à nCrunch.Compiler.Cil.CilModule..ctor(CilAssembly assembly, CilMetadataRoot metadataRoot, CilPeHeaders peHeaders, CilContext context, DirectoryPath workingDirectory, UInt32 entryPointToken)
à nCrunch.Compiler.Cil.CilAssembly..ctor(Byte[] , CilContext , DirectoryPath )
à nCrunch.Compiler.Cil.CilAssembly.Load(FilePath assemblyFile, CilContext context)
à nCrunch.Compiler.Cil.CachedCilAssembly..ctor(FilePath assemblyFilePath, CilContext context, Boolean isInstrumentationTarget)
à nCrunch.Compiler.Cil.CilSession.LoadAssembly(FilePath assemblyFilePath, Boolean isInstrumentationTarget)
à nCrunch.Compiler.StaticManipulation.BuiltCilAssembly..ctor(FilePath builtAssemblyFilePath, IList`1 adjustedAssemblyReferences, Boolean instrumentForPerformanceMeasurement, ComponentInstrumentationParameters instrumentationParameters, FilePath expectedForegroundBuildOutputPath)
à nCrunch.Compiler.RemoteBuildRunner..()
à nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
à nCrunch.Compiler.RemoteBuildRunner.(ComponentInstrumentationParameters , BuildOutput , IBackgroundTaskProcessor )
à nCrunch.Compiler.RemoteBuildRunner.PerformPostProcessingOfBuiltAssembly(ComponentInstrumentationParameters instrumentationParameters, BuildOutput output, IBackgroundTaskProcessor backgroundTaskProcessor)
à nCrunch.Core.BuildManagement.BuildEnvironment..()
à nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
à nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridAddress clientAddress, Boolean extractCoverageReportStructure)
à nCrunch.Core.Processing.BuildTaskLogic.DoProcessTaskAndReturnSuccessFlag()
à nCrunch.Core.Processing.TaskLogic.ProcessTaskAndReturnSuccessFlag()
à nCrunch.Client.Processing.LocalProcessingTask.ProcessTaskAndReturnSuccessFlag()
à nCrunch.Client.Processing.ProcessingQueue..()

Vincent
#6 Posted : Monday, November 22, 2021 4:30:37 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/1/2017(UTC)
Posts: 7
Location: France

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
With version 4.0.0.2, the error is slightly different:

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/d...ng_project-build-issues
System.ArgumentOutOfRangeException: L'argument spécifié n'était pas dans les limites de la plage des valeurs valides.
à _Mono.Collections.Generic.Collection`1.get_Item(Int32 index)
à _Mono.Cecil.SignatureReader.GetGenericParameter(GenericParameterType type, UInt32 var)
à _Mono.Cecil.SignatureReader.ReadTypeSignature(ElementType etype)
à _Mono.Cecil.SignatureReader.ReadGenericInstanceSignature(IGenericParameterProvider provider, IGenericInstance instance)
à _Mono.Cecil.SignatureReader.ReadTypeSignature(ElementType etype)
à _Mono.Cecil.MetadataReader.GetTypeSpecification(UInt32 rid)
à _Mono.Cecil.MetadataReader.LookupToken(MetadataToken token)
à _Mono.Cecil.MetadataReader.ReadTypeMemberReference(MetadataToken type, String name, UInt32 signature)
à _Mono.Cecil.MetadataReader.ReadMemberReference(UInt32 rid)
à _Mono.Cecil.MetadataReader.GetMemberReference(UInt32 rid)
à _Mono.Cecil.MetadataReader.LookupToken(MetadataToken token)
à _Mono.Cecil.MetadataReader.GetMethodSpecification(UInt32 rid)
à _Mono.Cecil.MetadataReader.LookupToken(MetadataToken token)
à _Mono.Cecil.Cil.CodeReader.ReadOperand(Instruction instruction)
à _Mono.Cecil.Cil.CodeReader.ReadCode()
à _Mono.Cecil.Cil.CodeReader.ReadMethodBody()
à _Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
à _Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)
à _Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
à _Mono.Cecil.MethodDefinition.get_Body()
à nCrunch.Compiler.OldStaticManipulation.Instrumentor.(Collection`1 )
à nCrunch.Compiler.OldStaticManipulation.Instrumentor.(IEnumerable`1 )
à nCrunch.Compiler.OldStaticManipulation.Instrumentor.InstrumentTypes()
à nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
à nCrunch.Compiler.OldStaticManipulation.BuiltAssembly.Instrument(IInstrumentationFilter[] instrumentationFilters, PerfTracker perfTracker)
à nCrunch.Compiler.CilProcessingTasks.CilInstrumentationTask.ProcessTask(IBuiltAssembly builtAssembly, ComponentInstrumentationParameters instrumentationParameters, BuildOutput output)
à nCrunch.Compiler.RemoteBuildRunner.(ComponentInstrumentationParameters , BuildOutput , IBackgroundTaskProcessor )
à nCrunch.Compiler.RemoteBuildRunner..()
à nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
à nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters , ComponentInstrumentationParameters )

Remco
#7 Posted : Monday, November 22, 2021 11:13:36 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

There's been a number of fixes in this area over previous years. The exceptions thrown here before the latest version of the product are from issues that have already been resolved.

I haven't seen this before on v4.11 however. Would you mind submitting a bug report after you've had this happen to you? Are you able to build a sample product that can reproduce the issue and you can share with me?
Vincent
#8 Posted : Tuesday, November 23, 2021 9:02:29 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/1/2017(UTC)
Posts: 7
Location: France

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Remco;15830 wrote:
Hi, thanks for sharing this issue.

There's been a number of fixes in this area over previous years. The exceptions thrown here before the latest version of the product are from issues that have already been resolved.

I haven't seen this before on v4.11 however.


I'm reproducing it with 4.11.0.2

Remco;15830 wrote:

Would you mind submitting a bug report after you've had this happen to you?

Done.

Remco;15830 wrote:
Are you able to build a sample product that can reproduce the issue and you can share with me?

No, I have no clue why the build fails and the solution is huge.
Remco
#9 Posted : Tuesday, November 23, 2021 10:53:03 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Quote:

No, I have no clue why the build fails and the solution is huge.


Unfortunately, to have any hope of resolving this problem, we'll need to have a copy of a project that produces it or the assembly produced by building it. I understand that given IP constraints, this is not usually a reasonable thing to ask, but with a large project we have no hope of being able to reproduce such an issue through experimentation. If you'd like to submit code or the assembly involved, you can do so via the NCrunch contact form (to a size limit of 10MB).

The error suggests that the assembly itself has an unusual structure that doesn't fit with the expectations of NCrunch's instrumentation system. This could be related to the size of the assembly or some kind of post-compilation processing that has been performed on it.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.088 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download