Build/Test Issues

csc.exe -2146232797 NullReferenceException since 2.23

Started by Kelon on 3,732 views

Hi,
First post as a long year customer - and it's a reproducable error report.
Our team uses ncrunch because we love the great code coverage support. But since 2.23, we've had a build failure which prevented any product updates (2.22.0.1 succeeds). Finally we've found the issue of the failure.
The MSBuild (by Visual Studio) runs fine, but ncrunch just displays the failure:

..\..\..\..\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets (67, 5): "csc.exe" wurde mit dem Code -2146232797 beendet.


You'll get a better description by windows, visiting its event viewer:
Anwendung: csc.exe
Frameworkversion: v4.0.30319
Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet.
Ausnahmeinformationen: System.NullReferenceException
bei Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEEventSymbol.DoesSignatureMatch(Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEModuleSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol)
bei Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEEventSymbol.DoSignaturesMatch(Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEModuleSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol)
bei Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEEventSymbol..ctor(Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEModuleSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PENamedTypeSymbol, System.Reflection.Metadata.EventDefinitionHandle, Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol, Roslyn.Utilities.MultiDictionary`2<System.String,Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEFieldSymbol>)
bei Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PENamedTypeSymbol.CreateEvents(Roslyn.Utilities.MultiDictionary`2<System.String,Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEFieldSymbol>, System.Collections.Generic.Dictionary`2<System.Reflection.Metadata.MethodDefinitionHandle,Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol>, Microsoft.CodeAnalysis.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.Symbol>)
bei Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PENamedTypeSymbol.LoadMembers()
bei Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PENamedTypeSymbol.GetMembers(System.String)
bei Microsoft.CodeAnalysis.CSharp.Symbols.OverriddenOrHiddenMembersHelpers.FindOverriddenOrHiddenMembersInType(Microsoft.CodeAnalysis.CSharp.Symbol, Boolean, Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol, Microsoft.CodeAnalysis.CSharp.Symbol ByRef, Boolean ByRef, Microsoft.CodeAnalysis.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.Symbol> ByRef)
bei Microsoft.CodeAnalysis.CSharp.Symbols.OverriddenOrHiddenMembersHelpers.MakeOverriddenOrHiddenMembersWorker(Microsoft.CodeAnalysis.CSharp.Symbol)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourcePropertySymbol.get_OverriddenOrHiddenMembers()
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.CheckMembersAgainstBaseType(Microsoft.CodeAnalysis.DiagnosticBag, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetSynthesizedExplicitImplementations(System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.ForceComplete(Microsoft.CodeAnalysis.SourceLocation, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.Symbol.ForceCompleteMemberByLocation(Microsoft.CodeAnalysis.SourceLocation, Microsoft.CodeAnalysis.CSharp.Symbol, System.Threading.CancellationToken)
bei Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass6_0`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<WithCurrentUICulture>b__0(Int32)
bei System.Threading.Tasks.Parallel+<>c__DisplayClass17_0`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<ForWorker>b__1()
bei System.Threading.Tasks.Task.InnerInvokeWithArg(System.Threading.Tasks.Task)
bei System.Threading.Tasks.Task+<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(System.Object)

Ausnahmeinformationen: System.AggregateException
bei System.Threading.Tasks.Task.ThrowIfExceptional(Boolean)
bei System.Threading.Tasks.Task.Wait(Int32, System.Threading.CancellationToken)
bei System.Threading.Tasks.Parallel.ForWorker[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>, System.Action`2<Int32,System.Threading.Tasks.ParallelLoopState>, System.Func`4<Int32,System.Threading.Tasks.ParallelLoopState,System.__Canon,System.__Canon>, System.Func`1<System.__Canon>, System.Action`1<System.__Canon>)
bei System.Threading.Tasks.Parallel.For(Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamespaceSymbol.ForceComplete(Microsoft.CodeAnalysis.SourceLocation, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.Symbol.ForceCompleteMemberByLocation(Microsoft.CodeAnalysis.SourceLocation, Microsoft.CodeAnalysis.CSharp.Symbol, System.Threading.CancellationToken)
bei Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass6_0`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<WithCurrentUICulture>b__0(Int32)
bei System.Threading.Tasks.Parallel+<>c__DisplayClass17_0`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<ForWorker>b__1()
bei System.Threading.Tasks.Task.InnerInvokeWithArg(System.Threading.Tasks.Task)
bei System.Threading.Tasks.Task+<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(System.Object)

Ausnahmeinformationen: System.AggregateException
bei System.Threading.Tasks.Task.ThrowIfExceptional(Boolean)
bei System.Threading.Tasks.Task.Wait(Int32, System.Threading.CancellationToken)
bei System.Threading.Tasks.Parallel.ForWorker[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>, System.Action`2<Int32,System.Threading.Tasks.ParallelLoopState>, System.Func`4<Int32,System.Threading.Tasks.ParallelLoopState,System.__Canon,System.__Canon>, System.Func`1<System.__Canon>, System.Action`1<System.__Canon>)
bei System.Threading.Tasks.Parallel.For(Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamespaceSymbol.ForceComplete(Microsoft.CodeAnalysis.SourceLocation, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.Symbol.ForceCompleteMemberByLocation(Microsoft.CodeAnalysis.SourceLocation, Microsoft.CodeAnalysis.CSharp.Symbol, System.Threading.CancellationToken)
bei Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass6_0`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<WithCurrentUICulture>b__0(Int32)
bei System.Threading.Tasks.Parallel+<>c__DisplayClass17_0`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<ForWorker>b__1()
bei System.Threading.Tasks.Task.InnerInvokeWithArg(System.Threading.Tasks.Task)
bei System.Threading.Tasks.Task+<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(System.Object)

Ausnahmeinformationen: System.AggregateException
bei System.Threading.Tasks.Task.ThrowIfExceptional(Boolean)
bei System.Threading.Tasks.Task.Wait(Int32, System.Threading.CancellationToken)
bei System.Threading.Tasks.Parallel.ForWorker[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>, System.Action`2<Int32,System.Threading.Tasks.ParallelLoopState>, System.Func`4<Int32,System.Threading.Tasks.ParallelLoopState,System.__Canon,System.__Canon>, System.Func`1<System.__Canon>, System.Action`1<System.__Canon>)
bei System.Threading.Tasks.Parallel.For(Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1<Int32>)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamespaceSymbol.ForceComplete(Microsoft.CodeAnalysis.SourceLocation, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceModuleSymbol.ForceComplete(Microsoft.CodeAnalysis.SourceLocation, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.Symbols.SourceAssemblySymbol.ForceComplete(Microsoft.CodeAnalysis.SourceLocation, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSourceDeclarationDiagnostics(Microsoft.CodeAnalysis.SyntaxTree, System.Nullable`1<Microsoft.CodeAnalysis.Text.TextSpan>, System.Func`4<System.Collections.Generic.IEnumerable`1<Microsoft.CodeAnalysis.Diagnostic>,Microsoft.CodeAnalysis.SyntaxTree,System.Nullable`1<Microsoft.CodeAnalysis.Text.TextSpan>,System.Collections.Generic.IEnumerable`1<Microsoft.CodeAnalysis.Diagnostic>>, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetDiagnostics(Microsoft.CodeAnalysis.CompilationStage, Boolean, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetDeclarationDiagnostics(System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CommonCompiler.RunCore(System.IO.TextWriter, Microsoft.CodeAnalysis.ErrorLogger, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CommonCompiler.Run(System.IO.TextWriter, System.Threading.CancellationToken)
bei Microsoft.CodeAnalysis.CSharp.CommandLine.Csc+<>c__DisplayClass1_0.<Run>b__0(System.IO.TextWriter)
bei Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Func`2<System.IO.TextWriter,Int32>)
bei Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(System.String[], Microsoft.CodeAnalysis.CommandLine.BuildPaths, System.IO.TextWriter, Microsoft.CodeAnalysis.IAnalyzerAssemblyLoader)
bei Microsoft.CodeAnalysis.CommandLine.DesktopBuildClient.RunLocalCompilation(System.String[], Microsoft.CodeAnalysis.CommandLine.BuildPaths, System.IO.TextWriter)
bei Microsoft.CodeAnalysis.CommandLine.BuildClient.RunCompilation(System.Collections.Generic.IEnumerable`1<System.String>, Microsoft.CodeAnalysis.CommandLine.BuildPaths, System.IO.TextWriter)
bei Microsoft.CodeAnalysis.CommandLine.DesktopBuildClient.Run(System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IEnumerable`1<System.String>, Microsoft.CodeAnalysis.CommandLine.RequestLanguage, Microsoft.CodeAnalysis.CommandLine.CompileFunc, Microsoft.CodeAnalysis.IAnalyzerAssemblyLoader)
bei Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(System.String[], System.String[])
bei Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(System.String[])


And after a lot of trial and error, the failure issue seems to be using [ExcludeFromCodeCoverage] at event functions, but only on their derrivates.



To reproduce, create 2 projects:
Project 1: NCrunchCsc
using System;
using System.Diagnostics.CodeAnalysis;

namespace NCrunchCsc
{
	public class Class1
	{
		public event EventHandler Acting
		{
			[ExcludeFromCodeCoverage /* NullReferenceException*/]
			add { }
			remove { }
		}
	}
}


Project 2: Inherit
using NCrunchCsc;

namespace Inherit
{
	public class InheritClass1 : Class1
	{
	}
}


This prevents ncrunch from building any derrived projects.



An easy way to pass is replacing the attribute with its comment line exclusion:
using System;

namespace NCrunchCsc
{
	public class Class1
	{
		public event EventHandler Acting
		{
			//ncrunch: no coverage start
			add { }
			remove { }
			//ncrunch: no coverage end
		}
	}
}


Hi, thanks for sharing this problem. I appreciate the difficulty of narrowing this down, you've done very well here.

I can confirm that I can reproduce the problem exactly as described. It looks like an instrumentation issue. I'll see what I can do about getting it fixed in the next release. Thanks again for making me aware of it.
There's probably a similiar problem with property functions (get, set)


		private string name;
		public string Name
		{
			[ExcludeFromCodeCoverage /* Seems to be cut out */]
			get { return this.name; }
			set{ this.name = value; }
		}



sut.Name = "Foo";
var result = sut.Name;


Even though it compiles, the error states that the property has no getter.
Well, in this case it sounds like a feature, because the property isn't excluded from coverage, otherwise the error wouldn't occur *g*

Post a reply

Log in to reply.