Visual Studio 2013 Profiler chrashes and system restarts / reboots

I'm having a HP Z440 Workstation (E5-1680v4 and 128 GB RAM, BIOS 2.39 Rev.A) and I'm using Visual Studio Professional 2013 (Update 5). The operation system is Windows 7 64-bit.

When I'm using the Profiler from Visual Studio in a C# project for example it crashes and it restarts / reboots my PC.

The following steps reproduce the problem:

  1. Start PC and open Visual Studio
  2. Create a C# console application (.NET 4.0)
  3. Add Console.WritLine("Hello World :-("); to main method.
  4. Menu / Analyze / Performance and Diagnostics.
  5. CPU sammpling.
  6. Select the project HelloWorld for example.
  7. All information needed to create a performance sessions has been collect.
  8. Click on Finish (Lunch profiling after the wizard finishes checked).
  9. Clicking on the following dialog on yes. enter image description here
  10. Windows is asking for administrator credentials which I can provide him. enter image description here
  11. I can see for a second tab page (*.vsp) showing Start the profiler. After that the PC crashes and restarts / reboots.

I can see a critical error in the system log after the reboot:

The system has rebooted without cleanly shutting down first. This error could be caused if the system stopped responding, crashed, or lost power unexpectedly.

Any ideas what happens? Last year (2017) I was able to use the Profiler of Visual Studio 2013 on the same PC. The only things that were changed, were Windows Updates and the BIOS (do Meltdown and Spectre).

What can I do that I'm able again to profile my code?


Recently MS provided registry settings to disable the Spectre/Meltdown patches. If the security profile of your development environment can live with disabling those patches, these settings will allow the profiler to function again:

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverride /t REG_DWORD /d 3 /f

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverrideMask /t REG_DWORD /d 3 /f

Reboot, and the profiler should work again.

Source: https://support.microsoft.com/en-us/help/4073119/protect-against-speculative-execution-side-channel-vulnerabilities-in


This is caused by the January windows updates. It looks like this will not be fixed, see the following comments from Allen Denver:

I'm very sorry that you are seeing this problem occur. A recently released security patch for Windows 7 (the "Meltdown/Spectre" security patch) causes all versions of the Visual Studio Performance Wizard and the VSPerfCMD command line utility when used in the Sampling mode to restart the computer without warning or event log entries. This problem only affects sampling when used to gather CPU or .Net Memory Allocation stacks. The Instrumentation mode is unaffected. Likewise the Contention mode is also unaffected. Profiling operations supported on Windows 8+ are also unaffected by this issue.

The cause of this problem is that previously supported operations performed by the sampling profiler are no longer allowed after the security patch. The security patch modified the Windows 7 OS Kernel is such a way that the low-level data gathering code we use causes the machine to restart. No blue-screen and no event log entries are made when this occurs. The problem occurs even lower than these facilities of the OS. This cause is similar to the changes that were made to the Windows OS Kernel in Windows 8 which caused us to modify the Visual Studio Profiler significantly to use different techniques to collect the sampling profiling data. Windows 8 disallowed the collection technique used in Windows 7. Now, with the security patch, Windows 7 also disallows the technique.

Fortunately, there are a few workarounds I can recommend. These workarounds aren't perfect. There are limitations to them that we hope to address quickly in the future to fill the gaps, but these can be utilized to at least perform some performance profiling while we work to fill those gaps.

I have a lengthy document I'm working on that describes the workarounds in detail. It is too long for a single post here. So, I'll break it up in multiple responses to this entry. I'll also post a link to the single document when I have a place for it on the web.

Allen Denver

Visual Studio

and

We intend to release a patch that will avoid the restart behavior by disallowing the sampling collection session from starting. This is not a 'fix', however. We have no plans to make the Performance Explorer, Performance Wizard, VSPerfASPNetCMD or VSPerfCMD sampling work on Windows 7. Our way forward is with the CPU Usage tool and the Diagnostics Hub (aka "Performance Profiler").

Source: https://developercommunity.visualstudio.com/content/problem/177958/starting-the-profiler-leads-to-computer-restart-af.html

Workaround 1

For Windows 7 and Visual Studio 2013 there isn't a good workaround, see comment from Allen Denver:

For VS2013 and prior versions of Visual Studio you may use the Instrumentation method for profiling instead.

So you cannot use the CPU sampling mode with Windows 7 and Visual Studio 2013 anymore.

Workaround 2

I guess switching to Windows 10 and Visual Studio 2017 is the way to go, see as well the comment from Allen Denver:

The Performance Wizard and Performance Explorer profiling in Visual Studio 2017 using the sampling technique will work on Windows 10. In the case of Win 8+, we changed the collector to get stack traces using a different set of OS features, rather than our own Kernel driver.