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

Notification

Icon
Error

IndexOutOfRangeException with new instrumentation mode
mdenny
#1 Posted : Tuesday, November 12, 2019 5:52:50 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/6/2014(UTC)
Posts: 2
Location: Australia

Thanks: 1 times
I've just upgraded to NCrunch 4 and am experiencing an issue with one of our projects which no longer builds in NCrunch.
Stacktrace is below. Setting instrumentation mode back to "Default" corrects the issue. I tried clearing caches and resetting NCrunch. We're on 4.1.0.1 and I'm running VS2019 16.3.5 on .NET 4.8.
The "Reload and rebuild" right click option in the NCrunch Tests window appears to have gone as well.

Let me know if I can provide any more detail. Other than this blip, the new 4.0 release is great - hotspot is a fantastic new feature!

[15:05:59.0357-LocalBuildTask-82] ERROR (Internal): 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.CachedCilAssembly..ctor(FilePath assemblyFilePath, CilContext context, Boolean isInstrumentationTarget)
at nCrunch.Compiler.Cil.CilSession.LoadAssembly(FilePath assemblyFilePath, Boolean isInstrumentationTarget)
at nCrunch.Compiler.NewStaticManipulation.BuiltCilAssembly..ctor(FilePath builtAssemblyFilePath, IList`1 adjustedAssemblyReferences, Boolean instrumentForPerformanceMeasurement, ComponentInstrumentationParameters instrumentationParameters, ILogger logger)
at nCrunch.Compiler.RemoteBuildRunner..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentInstrumentationParameters , BuildOutput , IBackgroundTaskProcessor )
at nCrunch.Compiler.RemoteBuildRunner.PerformPostProcessingOfBuiltAssembly(ComponentInstrumentationParameters instrumentationParameters, BuildOutput output, IBackgroundTaskProcessor backgroundTaskProcessor)
at nCrunch.Core.BuildManagement.BuildEnvironment..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridAddress clientAddress)
at nCrunch.Core.Processing.BuildTaskLogic.DoProcessTaskAndReturnSuccessFlag()
at nCrunch.Core.Processing.TaskLogic.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.LocalProcessingTask.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.ProcessingQueue..()

Remco
#2 Posted : Tuesday, November 12, 2019 7:51:12 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,420

Thanks: 838 times
Was thanked: 1136 time(s) in 1062 post(s)
Hi, thanks for sharing this problem.

Would you be able to tell me a bit more about the project that's raised this exception?

Which language and platform is it targeting?

Is there any post-processing of the project's output assembly via IL weavers or other tooling?

Does the project contain any nested classes?

There is something unusual about an IL declaration in the project, so I'm hungry for more information that can help me reproduce the issue :)
mdenny
#3 Posted : Tuesday, November 12, 2019 10:46:06 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/6/2014(UTC)
Posts: 2
Location: Australia

Thanks: 1 times
Hi Remco,

It's using C# (8) Platform Any CPU.
The solution with the offending project is quite large and has many other projects, it's only one project which fails to build, and there's nothing particularly different about it from the other projects in the solution which succeed.
Nothing fancy with IL merging or anything like that, we do use Octopack on release builds but in debug it's pretty vanilla.
With regard to nested classes, there aren't any nested classes in the assembly that fails, it does reference a couple of assemblies with nested classes, however they are building successfully in Ncrunch...

I checked to see if we're using any of the new C# 8 language features in this project, and we're not.

If it helps (probably not) I'm pretty sure that the build was working a day or so ago, after I'd upgraded to NCrunch 4, but has stopped working since. I'll go through changes to see if anything unusual is there.
Sorry that I'm not much help!

Cheers,

Marcus
Remco
#4 Posted : Tuesday, November 12, 2019 11:06:50 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,420

Thanks: 838 times
Was thanked: 1136 time(s) in 1062 post(s)
mdenny;14061 wrote:

If it helps (probably not) I'm pretty sure that the build was working a day or so ago, after I'd upgraded to NCrunch 4, but has stopped working since. I'll go through changes to see if anything unusual is there.
Sorry that I'm not much help!


I can almost 100% say that this is caused by V4, so don't worry about chasing any of your commits :)

Somehow, the assembly from this project has a different structure to any other assembly we've instrumented before in our own V4 testing. It's not clear to me what could be causing this, as we've tested extensively over C# 8 assemblies under AnyCPU.

There must be some kind of post-processing (perhaps caused by a Nuget package) or something in the assembly declared that is making it different. If you're able to share the assembly with me, I can probably figure this out quite quickly, though I expect that with IP constraints that might be difficult. Is there any way you can deduct the problem down to a sample you can share with me? Either a project (with .cs files) or compiled .DLL is fine.
Skym_
#5 Posted : Monday, January 27, 2020 10:05:16 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/27/2020(UTC)
Posts: 1
Location: Germany

I stumbled across the same issue using ncrunch 4.2.0.7. Targeting .Net 4.6.2, AnyCPU, C# (7.3). I copied all C# files to a new solution with a new default C# .Net Framework Class Library project to show that it's not caused by a strange project file config or solution issue, and indeed ncrunch failed to build this project.

I found that by removing a property (that was causing a compiler warn) ncrunch successfully built the project. I then tried a few different ways of trying to make a reproducible case without my company's code involved, but it appears that it was nothing to do with the specific property, but rather something to do with the number of members/types in this project or overall, somehow, or something along those lines. I say this because I found that if I deleted other properties or other types in the project that seemed completely unrelated I would see a successful ncrunch build.

I should mention this is of course under Optimised Instrumentation, and setting it back to Default gives a successful build.

This was the (identical) exception

ERROR (Internal): 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.CachedCilAssembly..ctor(FilePath assemblyFilePath, CilContext context, Boolean isInstrumentationTarget)
at nCrunch.Compiler.Cil.CilSession.LoadAssembly(FilePath assemblyFilePath, Boolean isInstrumentationTarget)
at nCrunch.Compiler.NewStaticManipulation.BuiltCilAssembly..ctor(FilePath builtAssemblyFilePath, IList`1 adjustedAssemblyReferences, Boolean instrumentForPerformanceMeasurement, ComponentInstrumentationParameters instrumentationParameters, ILogger logger)
at nCrunch.Compiler.RemoteBuildRunner..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentInstrumentationParameters , BuildOutput , IBackgroundTaskProcessor )
at nCrunch.Compiler.RemoteBuildRunner.PerformPostProcessingOfBuiltAssembly(ComponentInstrumentationParameters instrumentationParameters, BuildOutput output, IBackgroundTaskProcessor backgroundTaskProcessor)
at nCrunch.Core.BuildManagement.BuildEnvironment..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridAddress clientAddress)
at nCrunch.Core.Processing.BuildTaskLogic.DoProcessTaskAndReturnSuccessFlag()
at nCrunch.Core.Processing.TaskLogic.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.LocalProcessingTask.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.ProcessingQueue..()

Let me know how to share more info, short of the full code, if there's a way.
Remco
#6 Posted : Monday, January 27, 2020 10:19:20 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,420

Thanks: 838 times
Was thanked: 1136 time(s) in 1062 post(s)
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.207 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download