5

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?

  • Downgrading the BIOS from V2.39 to V2.38 didn't solved the problem. The profiler still crashes the PC (black screen and reboot). – Wollmich Jan 23 '18 at 8:57
  • It happens as well on my Laptop an old HP 8540w (i7 Q740, 16 GB RAM, Windows 7 64-bit and Visual Studio 2013 Pro). It was as well working on this computer last year. Only windows updates were installed since then. – Wollmich Jan 23 '18 at 13:10
  • I can reproduce the crash as well on a HP 8300 CMT (i7 3770, 8 GB RAM, Windows 7 64-bit and Visual Studio 2013). It was working as well on this computer last year. So I guess this crash doesn't depend on the hardware. Are there other people out there having the same problem? – Wollmich Jan 24 '18 at 7:55
5

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

  • Thanks. It tried it and it worked. After setting this two registry settings the system doesn't crash anymore and the Profiler of Visual Studio 2013 is working again under Windows 7. But the Spectre/Meltdown patches are disabled. I think it's better to finally switch to Windows 10 and Visual Studio 2017. – Wollmich Mar 15 '18 at 9:02
  • Agreed. OTOH for me the automation support provided under Win7 is critical. The command line tools provided for profiling under Win10 make it much harder to have something happen after the profile run finishes. So I am not moving yet, at least on one lab machine where I don't read email. – aap Mar 16 '18 at 14:13
3

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.

  • You should include the current workaround for this problem. – Ramhound Jan 24 '18 at 16:26
  • Still doesn't change the fact you should include the current workaround. – Ramhound Jan 29 '18 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.