FIX: OutputDebugString() Without \n May GP Fault in MSVC.EXE

Last reviewed: September 18, 1997
Article ID: Q123493
2.00 WINDOWS NT kbtool kbfixlist kbfile

The information in this article applies to:

  • The Visual Workbench Integrated Debugger included with:

        - Microsoft Visual C++, version 1.5
        - Microsoft Visual C++, 32-bit Edition, version 2.0
    

SYMPTOMS

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.

CAUSE

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.

RESOLUTION

Avoid passing strings that do not have an appended newline character to OutputDebugString(), TRACE(), and CDumpContext objects.

STATUS

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.

Download VC1501.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download VC1501.EXE (size: 81078 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get VC1501.EXE (size: 81078 bytes) 
    

MORE INFORMATION

Steps to Reproduce Problem

  1. Add the following code to an executable portion of your application:

       int i;
       for (i=0; i<500; i++)
          OutputDebugString( "This is a test!!!" );
    
    

  2. Rebuild the application, and run it (press the F5 key) such that the Debug Output window is hidden.

  3. 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.


Additional reference words: 2.00 GPF buglist2.00
KBCategory: kbtool kbfixlist kbbuglist kbfile
KBSubcategory: WBDebug
Keywords : WBDebug kbbuglist kbfile kbfixlist kbtool
Technology : kbMfc
Version : 2.00
Platform : NT WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.