runtime: System.AccessViolationException while formatting stacktrace

Reported by @BrennanConroy

We’re getting this exception in a test occasionally.

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at System.Reflection.Internal.MemoryBlock.PeekCompressedInteger(Int32 offset, Int32& numberOfBytesRead)
    at System.Reflection.Metadata.Ecma335.BlobHeap.GetMemoryBlock(BlobHandle handle)
    at System.Reflection.Metadata.MethodDebugInformation.GetSequencePoints()
    at System.Diagnostics.StackTraceSymbols.GetSourceLineInfoWithoutCasAssert(String assemblyPath, IntPtr loadedPeAddress, Int32 loadedPeSize, IntPtr inMemoryPdbAddress, Int32 inMemoryPdbSize, Int32 methodToken, Int32 ilOffset, String& sourceFile, Int32& sourceLine, Int32& sourceColumn)
    at System.Diagnostics.StackFrameHelper.InitializeSourceInfo(Int32 iSkip, Boolean fNeedFileInfo, Exception exception)
    at System.Diagnostics.StackTrace.CaptureStackTrace(Int32 iSkip, Boolean fNeedFileInfo, Thread targetThread, Exception e)
    at System.Diagnostics.StackTrace..ctor(Exception e, Boolean fNeedFileInfo)
    at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
    at System.Exception.GetStackTrace(Boolean needFileInfo)
    at System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
    at System.Exception.ToString()

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 26 (25 by maintainers)

Most upvoted comments

@jnm2 We continue to both service and support .NET Framework, which includes bug–, reliability– and security fixes. https://devblogs.microsoft.com/dotnet/net-core-is-the-future-of-net/

This issue is both reliability and security use-after-free bug as you have pointed out. I am asking folks to reconsider.

The .NET Framework fix is scheduled for November update.

@mikem8361 is working on it. I am sorry it has been delayed due to summer vacations.

@jkotas Would it be possible to have the status of the .NET Framework bug? This is a major issue for us, randomly and abruptly killing our production services.

.NET Framework bugs are not tracked on github. They are tracked in internal bug database. This specific bug is tracked as https://devdiv.visualstudio.com/DevDiv/_workitems/edit/672340

https://github.com/dotnet/core#getting-help has instruction for opening .NET Framework issues. If you would like to have something you can see and monitor progress from outside, you can open a .NET Framework issue there.

@tommcdon That’s disappointing and I have to admit it leaves me curious, but thank you for considering. There are a number of other folks using NUnit and coming at this same .NET use-after-free bug from various directions. Is the rationale that .NET Framework 4.8 is intentionally less supported to nudge folks to .NET Core/.NET 5? That would be helpful to know as NUnit plans around this bug and as something we can pass on to folks who are affected by this.

@mikem8361 Do you plan to fix in .NET Framework 4.8 as well?