Microsoft KB Archive/251362

= Visual C++ Debugger hangs after you suspend and resume a thread =

Article ID: 251362

Article Last Modified on 8/7/2007

-

APPLIES TO


 * The Integrated Debugger, when used with:
 * Microsoft Visual C++ 6.0 Service Pack 5

-



This article was previously published under Q251362



SYMPTOMS
When debugging in the thread dialog box, suspend one of the threads and then continue debugging. When the debugger stops on another breakpoint, resume the suspend thread. As a result, the debugger stops responding, or hangs, and CPU utilization may go to 100%.



CAUSE
Under a debug build, every function call is prefixed with MOVESI, ESP (code bytes: 8B F4) for the run-time check feature (/GZ). Thus, if you set a breakpoint on any function call, the 8B is replaced with CC (INT 3) in memory to generate a user-defined exception. Before execution continues, the debugger replaces the CC with the original byte (in this case, 8B).

The debugger ignores the first user-defined exception (0x80000003) for the breakpoint that was set. The byte after the 8B is F4. F4 is a HLT instruction which is a privileged instruction; when this instruction executes, a privileged instruction exception (0xC0000096) is generated. The debugger remains ignoring exceptions, but unlike the user-defined exception, the instruction pointer isn't advanced and when the debugger ignores this exception, the exception is generated again thus entering an endless loop.



RESOLUTION
One workaround is to use MsgBox to simulate the suspend of thread.

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Visual Studio 6.0 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

Note If this product was already installed on your computer when you purchased it from the Original Equipment Manufacturer (OEM) and you need this fix, please call the Pay Per Incident number listed on the above Web site. If you contact Microsoft to obtain this fix, a fee may be charged. This fee is refundable if it is determined that you only require the fix you requested. However, this fee is non-refundable if you request additional technical support, if your no-charge technical support period has expired, or if you are not eligible for standard no-charge technical support.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0.

For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That a Visual Studio Service Pack Is Installed

To download the latest Visual Studio service pack, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx



Sample code
//  - Set a breakpoint on the printf statement in ThreadMain. //  - Start debugging the program. //  - When the breakpoint is reached suspend the thread the breakpoint //    occurred in. //  - Press F5. //  - When the breakpoint is reached resume the previously suspended //    thread. //  - Press F5. //  - Note that the breakpoint in now not reached again and that CPU //    usage is 100%. // // Required compiler switches: /GZ // void ThreadMain(void *data) {   for(int count=0; count<100; count++ ) {       printf("Thread id=%d,count=%d\n", (int)data, count ); Sleep( 1000 ); }   _endthread; }
 * 1) include 
 * 2) include 
 * 3) include 

void main(void) {   HANDLE ThreadId[2]; for (int i= 0; i < 2; i++) {       Sleep(500); ThreadId[i]=(HANDLE)_beginthread(ThreadMain, 0, (void *) i); }   WaitForMultipleObjects( 2, ThreadId, TRUE, INFINITE ); }

Additional query words: sp4

Keywords: kbqfe kbhotfixserver kbcode kbbug kbfix kbide kbvs600sp4fix kbvs600sp5fix KB251362

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.