runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Metadata reader CanReadFromSameMemoryMappedPEReaderInParallel test failed in CI

Open stephentoub opened this issue 11 years ago • 24 comments

http://dotnet-ci.cloudapp.net/job/dotnet_corefx_prtest/257/

System.Reflection.Metadata.Tests.MetadataReaderTests.CanReadFromSameMemoryMappedPEReaderInParallel [FAIL]
        System.AggregateException : One or more errors occurred.
        ---- System.BadImageFormatException : Invalid COR20 header signature.
        ---- System.BadImageFormatException : Invalid COR20 header signature.
        Stack Trace:
  Discovered:  System.ComponentModel.Primitives.Tests
              at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
              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)
           --- End of stack trace from previous location where exception was thrown ---
              at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
              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)
              at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\tests\Metadata\MetadataReaderTests.cs(2457,0): at System.Reflection.Metadata.Tests.MetadataReaderTests.CanReadFromSameMemoryMappedPEReaderInParallel()
           ----- Inner Stack Trace dotnet/corefx#1 (System.BadImageFormatException) -----
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(173,0): at System.Reflection.Metadata.MetadataReader.ReadMetadataHeader(BlobReader& memReader)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(97,0): at System.Reflection.Metadata.MetadataReader..ctor(Byte* metadata, Int32 length, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\PEReaderExtensions.cs(71,0): at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\PEReaderExtensions.cs(47,0): at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\tests\Metadata\MetadataReaderTests.cs(2457,0): at System.Reflection.Metadata.Tests.MetadataReaderTests.<>c__DisplayClass2c.<CanReadFromSameMemoryMappedPEReaderInParallel>b__2a(Int32 _)
              at System.Threading.Tasks.Parallel.<>c__DisplayClass9`1.<ForWorker>b__12(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
           --- End of stack trace from previous location where exception was thrown ---
              at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
              at System.Threading.Tasks.Parallel.<>c__DisplayClass9`1.<ForWorker>b__12(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
              at System.Threading.Tasks.TaskReplicator.Replica.Execute()
           ----- Inner Stack Trace dotnet/corefx#2 (System.BadImageFormatException) -----
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(173,0): at System.Reflection.Metadata.MetadataReader.ReadMetadataHeader(BlobReader& memReader)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(97,0): at System.Reflection.Metadata.MetadataReader..ctor(Byte* metadata, Int32 length, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\PEReaderExtensions.cs(71,0): at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\PEReaderExtensions.cs(47,0): at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\tests\Metadata\MetadataReaderTests.cs(2457,0): at System.Reflection.Metadata.Tests.MetadataReaderTests.<>c__DisplayClass2c.<CanReadFromSameMemoryMappedPEReaderInParallel>b__2a(Int32 _)
              at System.Threading.Tasks.Parallel.<>c__DisplayClass9`1.<ForWorker>b__12(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
           --- End of stack trace from previous location where exception was thrown ---
              at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
              at System.Threading.Tasks.Parallel.<>c__DisplayClass9`1.<ForWorker>b__12(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
              at System.Threading.Tasks.TaskReplicator.Replica.Execute()

stephentoub avatar Feb 27 '15 19:02 stephentoub

This failed again at http://dotnet-ci.cloudapp.net/job/dotnet_corefx_windows_release_prtest/555/console:

 Discovering: System.Reflection.Metadata.Tests
  Discovered:  System.Reflection.Metadata.Tests
  Starting:    System.Reflection.Metadata.Tests
  xUnit.net console test runner (32-bit .NET Core)
  Copyright (C) 2014 Outercurve Foundation.

System.Reflection.Metadata.Tests.MetadataReaderTests.CanReadFromSameMemoryMappedPEReaderInParallel [FAIL]
        System.AggregateException : One or more errors occurred.
        ---- System.BadImageFormatException : Invalid COR20 header signature.
        Stack Trace:
              at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
              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)
           --- End of stack trace from previous location where exception was thrown ---
              at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
              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)
              at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
           d:\j\workspace\dotnet_corefx_windows_release_prtest\src\System.Reflection.Metadata\tests\Metadata\MetadataReaderTests.cs(2457,0): at System.Reflection.Metadata.Tests.MetadataReaderTests.CanReadFromSameMemoryMappedPEReaderInParallel()
           ----- Inner Stack Trace -----
           d:\j\workspace\dotnet_corefx_windows_release_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(170,0): at System.Reflection.Metadata.MetadataReader.ReadMetadataHeader(BlobReader& memReader)
           d:\j\workspace\dotnet_corefx_windows_release_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(97,0): at System.Reflection.Metadata.MetadataReader..ctor(Byte* metadata, Int32 length, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_release_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\PEReaderExtensions.cs(70,0): at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_release_prtest\src\System.Reflection.Metadata\tests\Metadata\MetadataReaderTests.cs(2457,0): at System.Reflection.Metadata.Tests.MetadataReaderTests.<>c__DisplayClass2c.<CanReadFromSameMemoryMappedPEReaderInParallel>b__2a(Int32 _)
              at System.Threading.Tasks.Parallel.<>c__DisplayClass8`1.<ForWorker>b__10(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
           --- End of stack trace from previous location where exception was thrown ---
              at System.Threading.Tasks.Parallel.<>c__DisplayClass8`1.<ForWorker>b__10(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
              at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
              at System.Threading.Tasks.TaskReplicator.Replica.Execute()

stephentoub avatar Mar 25 '15 20:03 stephentoub

And again! http://dotnet-ci.cloudapp.net/job/dotnet_corefx_windows_debug_prtest/557/console

System.Reflection.Metadata.Tests.MetadataReaderTests.CanReadFromSameMemoryMappedPEReaderInParallel [FAIL]
        System.AggregateException : One or more errors occurred.
        ---- System.BadImageFormatException : Invalid COR20 header signature.
        Stack Trace:
  Discovered:  System.Collections.Concurrent.Tests
              at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
              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)
           --- End of stack trace from previous location where exception was thrown ---
              at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
              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)
              at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\tests\Metadata\MetadataReaderTests.cs(2457,0): at System.Reflection.Metadata.Tests.MetadataReaderTests.CanReadFromSameMemoryMappedPEReaderInParallel()
           ----- Inner Stack Trace -----
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(170,0): at System.Reflection.Metadata.MetadataReader.ReadMetadataHeader(BlobReader& memReader)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\MetadataReader.cs(97,0): at System.Reflection.Metadata.MetadataReader..ctor(Byte* metadata, Int32 length, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\PEReaderExtensions.cs(71,0): at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\src\System\Reflection\Metadata\PEReaderExtensions.cs(47,0): at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader)
           d:\j\workspace\dotnet_corefx_windows_debug_prtest\src\System.Reflection.Metadata\tests\Metadata\MetadataReaderTests.cs(2457,0): at System.Reflection.Metadata.Tests.MetadataReaderTests.<>c__DisplayClass2c.<CanReadFromSameMemoryMappedPEReaderInParallel>b__2a(Int32 _)
              at System.Threading.Tasks.Parallel.<>c__DisplayClass8`1.<ForWorker>b__10(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
           --- End of stack trace from previous location where exception was thrown ---
              at System.Threading.Tasks.Parallel.<>c__DisplayClass8`1.<ForWorker>b__10(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
              at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
              at System.Threading.Tasks.TaskReplicator.Replica.Execute()

stephentoub avatar Mar 25 '15 20:03 stephentoub

Possibly related: I get a similar error when trying to compile C# code with Roslyn in the context of the Jetbrains Reshaper test runner. That has never happend before, but now happens almost always when executing the entire test suite. It doesn't happen when I only execute a small amount of tests. It seems to be random which test fails, but its usually at the end of the test run.

error CS0009: Metadata file 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll' could not be opened -- Invalid COR20 header signature.

I've also seen other (non-GAC) assemblies that fail with an invalid COR20 header signature randomly. However, it only happens on my computer. My colleagues and the build server so far are not affected. I'm using the latest NuGet version of Roslyn.

axel-habermaier avatar Apr 21 '15 12:04 axel-habermaier

I don't believe we've seen this issue in almost a year. I'm going to close it. If it happens again, we can reopen.

stephentoub avatar Feb 15 '16 12:02 stephentoub

I don't believe we've seen this issue in almost a year. I'm going to close it. If it happens again, we can reopen.

This was silly... we haven't seen it happen because the test has been deactivated. If we believe the issue is fixed, we should remove the [ActiveIssue].

stephentoub avatar Mar 25 '16 03:03 stephentoub

This is failing left and right in the Windows Nano Server outerloop in the /release/1.0.0 branch. Tagging as blocking-clean-ci and moving up to 1.0.0-rtm to track

http://dotnet-ci.cloudapp.net/job/dotnet_corefx/job/release_1.0.0/job/outerloop_winnano16_release_tst/7/consoleFull

19:07:31 Unhandled Exception: System.BadImageFormatException: Invalid COR20 header signature. 19:07:31 at System.Reflection.Metadata.MetadataReader.ReadMetadataHeader(BlobReader& memReader, String& versionString) 19:07:31 at System.Reflection.Metadata.MetadataReader..ctor(Byte* metadata, Int32 length, MetadataReaderOptions options, MetadataStringDecoder

/cc @Priya91

joshfree avatar May 31 '16 07:05 joshfree

@joshfree That looks like a completely separate issue. As Xunit is reporting a failure, the stack trace population is triggering an invalid image for the portable PDB. I suspect there's an issue causing a Windows PDB to be opened as a portable PDB. I would open a separate issue to track it.

cc @mikem8361

nguerrera avatar May 31 '16 17:05 nguerrera

See additional stack frames:

19:07:31 Unhandled Exception: System.BadImageFormatException: Invalid COR20 header signature.
19:07:31    at System.Reflection.Metadata.MetadataReader.ReadMetadataHeader(BlobReader& memReader, String& versionString)
19:07:31    at System.Reflection.Metadata.MetadataReader..ctor(Byte* metadata, Int32 length, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
19:07:31    at System.Reflection.Metadata.MetadataReaderProvider.GetMetadataReader(MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
19:07:31    at System.Diagnostics.StackTraceSymbols.GetReader(String assemblyPath, IntPtr loadedPeAddress, Int32 loadedPeSize, IntPtr inMemoryPdbAddress, Int32 inMemoryPdbSize)
19:07:31    at System.Diagnostics.StackTraceSymbols.GetSourceLineInfo(String assemblyPath, IntPtr loadedPeAddress, Int32 loadedPeSize, IntPtr inMemoryPdbAddress, Int32 inMemoryPdbSize, Int32 methodToken, Int32 ilOffset, String& sourceFile, Int32& sourceLine, Int32& sourceColumn)
19:07:31    at System.Diagnostics.StackFrameHelper.InitializeSourceInfo(Int32 iSkip, Boolean fNeedFileInfo, Exception exception)
19:07:31    at System.Diagnostics.StackTrace.CaptureStackTrace(Int32 iSkip, Boolean fNeedFileInfo, Thread targetThread, Exception e)
19:07:31    at System.Diagnostics.StackTrace..ctor(Exception e, Boolean fNeedFileInfo)
19:07:31    at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
19:07:31    at System.Exception.GetStackTrace(Boolean needFileInfo)
19:07:31    at Xunit.Sdk.ExceptionUtility.ConvertExceptionToFailureInformation(Exception ex, Int32 parentIndex, List`1 exceptionTypes, List`1 messages, List`1 stackTraces, List`1 indices)
19:07:31    at Xunit.Sdk.ExceptionUtility.ConvertExceptionToFailureInformation(Exception ex)
19:07:31    at Xunit.Sdk.TestFailed..ctor(ITest test, Decimal executionTime, String output, Exception ex)

nguerrera avatar May 31 '16 17:05 nguerrera

This has been fixed with corefx commit # 014d16cd98 and coreclr commit # 3a1eb3e7ae1

mikem8361 avatar May 31 '16 18:05 mikem8361

Issue https://github.com/dotnet/corefx/issues/8866

mikem8361 avatar May 31 '16 18:05 mikem8361

Seems like the bug was actually in System.Diagnostics.StackTrace and been fixed. @mikem8361 could you confirm this issue can be closed?

tmat avatar Nov 03 '16 01:11 tmat

Yes, this has been fixed.

mikem8361 avatar Nov 03 '16 18:11 mikem8361

Disabled test, reopen it.

KristinXie1 avatar Feb 24 '17 06:02 KristinXie1

https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs#L2639

KristinXie1 avatar Feb 27 '17 01:02 KristinXie1

What do I need to do? Enable the test? Can't you @Jiayili1 do that?

mikem8361 avatar Mar 07 '17 21:03 mikem8361

There were two distinct issues on this thread. The one @mikem8361 fixed is not the same as the root issue.

nguerrera avatar Mar 07 '17 21:03 nguerrera

Do we believe the root issue is still around, or should we try re-enabling it?

stephentoub avatar Mar 08 '17 12:03 stephentoub

I don't recall there being a deliberate fix. I suppose we could try re-enabling, though.

nguerrera avatar Mar 08 '17 15:03 nguerrera

Yes, there was a fix. See above.

mikem8361 avatar Mar 08 '17 19:03 mikem8361

@mikem8361 Are you referring to the fix for https://github.com/dotnet/corefx/issues/8866? It is not the same bug, but it was conflated with this one starting here

nguerrera avatar Mar 08 '17 19:03 nguerrera