Deadlocks and crashes when debugging after upgrade to VS2012

106 views Asked by At

My app uses a C++/CLI class which extends System.Windows.Forms.UserControl and wraps a native C++ class which does Direct3d9 rendering using the Effects framework. Everything was working great until we upgraded our solution from VS2010 SP1 to VS2012.

In production machines, the apps work great, even a little faster than before. But when debugging, I randomly get one of two possible errors:

  1. A call to LockRect on a texture stays blocked forever
  2. I get an access violation in C:\Windows\SysWOW64\nvd3dum.dll, version 9.18.13.3182.

I'm using Windows 7 Ultimate, 64 bits, with all latest updates. I'm using a dual monitor setup fed by a dual head Nvidia GeForce 210 GPU (one from the VGA output, another from the DVI with a DVI-to-VGA adapter).

Since this seems to be a graphics adapter problem, all I could think of was upgrading the Nvidia drivers to their latest version. This only made the errors even more frequent, rendering my dev box unusable for debugging. My coworkers have similar environments and don't experience this issue at all.

Perhaps the GPU has some physical damage? How can I check that? Any other tips on troubleshooting this?

1

There are 1 answers

0
dario_ramos On BEST ANSWER

Researching the LockRect block issue, I stumbled upon many claims stating that Direct3D9 is, by default, not thread safe.

That clicked on me. Recently, we parallelized some native code which updated the texture data directly (i.e. no dispatch). So there were concurrent calls to LockRect. People said that Present was the dangerous call, but I tried setting the CreateDevice D3DCREATE_MULTITHREADED behavior flag, and voila, now I'm debugging smoothly, no more crashes or deadlocks.

Warning: Activating the multithreaded flag is said to introduce a significant performance overhead, but in my case it was negligible (and I'm doing live video from a frame grabber).