SYMPTOMS
When you attempt to break into a running application by using the Visual C++ debugger, you may receive the following error message in the output window:
DBG: Break command failed within 3 seconds.
DBG: Potential deadlock. Soft broken.
Any further attempts to step through code are unsuccessful; only Go works to resume the process.
RESOLUTION
The easiest way to work around this problem is to set breakpoints rather than to perform a hard break at run time. However, there are times when this is not possible.
If you suspect that true deadlock is occurring in your application, you will have to determine its cause. See
Detecting Deadlocks in Multithreaded Win32 Applications by Ruediger R. Asche in the Microsoft Developer Library (MSDN) at:
If you suspect that your process just needs more than 3 seconds to wait for the synchronization object, consider setting a breakpoint immediately after the
WaitForSingleObject or
WaitForMultipleObjects call.
If your application is performing CPU-intensive activity when you need to break, one way to allow for easier debugging is to call the
Sleep function. By placing strategic calls to
Sleep, you allow the debugger to more successfully break into the running process. For example, you can use a macro that only evaluates to a
Sleep call when you are debugging:
#ifdef _DEBUG
#define DEBUGSLEEP Sleep(50)
#else
#define DEBUGSLEEP
#endif
If you continue to have problems when you use the DEBUGSLEEP macro, try increasing the time that you sleep by 50 after each test.