Microsoft KB Archive/123493

= OutputDebugString Without \n May GP Fault in MSVC.EXE =

Article ID: 123493

Article Last Modified on 8/5/2004

-

APPLIES TO

 The Integrated Debugger, when used with:  Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 2.0 Professional Edition 

-



This article was previously published under Q123493



SUMMARY
If character strings passed as arguments to the OutputDebugString API do not end with a newline character \n, corrupt output appears in the Integrated Debugger's Output Window. In addition, a general protection fault (GP) fault can occur in MSVC.EXE. The Microsoft Foundation Classes (MFC) TRACE macro and CDumpContext class both use the OutputDebugString API to send information to the Integrated Debugger's Output window. Therefore, using a character string without a newline character with the MFC TRACE macro or CDumpContext class, will also cause this problem. Avoid passing strings that do not have an appended newline character to OutputDebugString, TRACE, and CDumpContext objects. Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was not reproducible in Microsoft Visual C++, 32-bit Edition, version 4.0.

NOTE: Microsoft has released a patch to Visual C++ version 1.5 that will fix this problem. This patch will modify the Visual Workbench 1.50, the new one will be version 1.50.01.

The following files are available for download from the Microsoft Download Center:

VC1501.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.



Steps to Reproduce Problem
  Add the following code to an executable portion of your application: int i;     for (i=0; i<500; i++) OutputDebugString( "This is a test!!!" ); </li> Rebuild the application, and run it (press the F5 key) such that the Debug Output window is hidden.</li> While the loop of code is executing, switch to the Debug Output window, and scroll through the text. Or attempt to select a portion of the text using the mouse. You'll see garbage in the Output Window. Prolonged scrolling will occasionally generate a GP fault in MSVC.EXE.</li></ol>

Additional query words: GPF

Keywords: kbdownload kbbug kbfix kbide kbpatch kbfile kbdebug KB123493

-

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

© Microsoft Corporation. All rights reserved.