Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--blame-hang causing crash with AccessViolationException #3005

Closed
nick-beer opened this issue Aug 8, 2021 · 3 comments
Closed

--blame-hang causing crash with AccessViolationException #3005

nick-beer opened this issue Aug 8, 2021 · 3 comments

Comments

@nick-beer
Copy link

I'm using --blame-hang in an invocation to dotnet vstest (via a runsettings file) on an AzDO pipeline. In the logs, I can see that when the blame collector identifies a hang, it tries to create a dump of the hung process, but it's failing with the following AccessViolationException:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.WindowsHangDumper+NativeMethods.MiniDumpWriteDump(IntPtr, UInt32, Microsoft.Win32.SafeHandles.SafeFileHandle, MINIDUMP_TYPE, MINIDUMP_EXCEPTION_INFORMATION ByRef, IntPtr, IntPtr)
--------------------------------
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.WindowsHangDumper.CollectDump(System.Diagnostics.Process, System.String, Microsoft.TestPlatform.Extensions.BlameDataCollector.DumpTypeOption)
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.WindowsHangDumper.Dump(Int32, System.String, Microsoft.TestPlatform.Extensions.BlameDataCollector.DumpTypeOption)
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcessDumpUtility.HangDump(Int32, System.String, Microsoft.TestPlatform.Extensions.BlameDataCollector.DumpTypeOption, System.String, System.Action`1<System.String>)
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcessDumpUtility.StartHangBasedProcessDump(Int32, System.String, Boolean, System.String, System.Action`1<System.String>)
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.BlameCollector.CollectDumpAndAbortTesthost()
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.InactivityTimer+<>c__DisplayClass1_0.<.ctor>b__0(System.Object)
   at System.Threading.TimerQueueTimer+<>c.<.cctor>b__23_0(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.TimerQueueTimer.CallCallback(Boolean)
   at System.Threading.TimerQueueTimer.Fire(Boolean)
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback(Int32)

Because of this crash, the test host isn't aborted, which requires the pipeline stage to terminate at its given timeout.

We're using version 5.0.302 of the dotnet SDK on our pipeline agents. I have limited access to the agents, so I'm hoping maybe someone's seen this before, or has a troubleshooting step I can try? If not, I can try to gain access to one of the agents to track the issue down.

@nohwnd
Copy link
Member

nohwnd commented Aug 11, 2021

Hello, the windows hang dumper uses only this p\Invoke call, and there is no option to switch to the native hang dumper of .NET Core, I did it this way to keep it simpler. And to avoid depending on external executables (procdump) on Windows.

I haven't seen it fail in this yet. Does your code target net5.0 target framework? Or do you only build with 5.0 SDK and target older framework?

We could possibly add option to force the native 5.0 hang dumper on windows. But that would require code changes, and a new build, so it would take time.

@nick-beer
Copy link
Author

Our target framework is <TargetFramework>net5.0-windows</TargetFramework>. On our CI machines, we're using the dotnet-install scripts to install the SDK/runtime.

It also appears to be working-ish on some agents. On some agents, it's able to create a full dump that I can open and debug, but I'm not able to debug the mini dumps it creates. The visual studio debugger indicates that there was no compatible code running (although I know there was managed code running because I hand crafted the hang).

The various agents we run on all have different sets of software installed - what's really required for this collector to work correctly?

@nohwnd nohwnd mentioned this issue Sep 1, 2021
@nohwnd
Copy link
Member

nohwnd commented Sep 10, 2021

Once this is shipped you will be able to use the VSTEST_DUMP_FORCEPROCDUMP=1 env variable to force using procdump over the PInvoke call for hang dumps. You need procdump installed in your PATH. Easiest way to install it on azdo is via choco.

@nohwnd nohwnd closed this as completed Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants