FIX: You may experience handle leak-like symptoms when you use the _popen CRT function for application development in C++ .NET 2002 (892473)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition

SYMPTOMS

You may experience application handle leak-like symptoms when you use the _popen C run-time (CRT) function for application development. This problem occurs in Microsoft Visual C++ .NET 2002.

CAUSE

The CRT library does not close process handles that are opened by the _popen CRT function. This problem causes handle leak-like symptoms and lack of available system resources.

RESOLUTION

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 Microsoft Visual Studio .NET 2002 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: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.

Prerequisites

Visual Studio .NET 2002

Restart requirement

You do not have to restart your computer after you apply this hotfix.

Hotfix replacement information

This hotfix does not replace any other hotfixes.

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.
Date         Time   Version        Size    File name
--------------------------------------------------------------
08-Jan-2005  03:10                 10,467  Io.h
08-Jan-2005  03:33              2,634,502  Libc.lib
08-Jan-2005  03:37              2,950,432  Libcd.lib
08-Jan-2005  03:34              2,835,448  Libcmt.lib
08-Jan-2005  03:38              3,198,282  Libcmtd.lib
08-Jan-2005  04:24  7.0.9960.0    339,968  Msvcr70.dll 
08-Jan-2005  03:39  7.0.9960.0    536,576  Msvcr70d.dll 
08-Jan-2005  03:10                 17,411  Popen.c
08-Jan-2005  03:10                  9,959  Read.c
10-Jan-2005  21:46                196,608  Vc_crt.msm
08-Jan-2005  04:24  7.0.9960.0    339,968  Msvcr70.dll

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. Start Visual Studio .NET 2003.
  2. On the File menu, click New, and then click Project.
  3. In the New Project window, click the Win32 Visual C++ project type, click the Win32 Console Project template, type AppName in the Name box, type drive_letter://yourpath, and then click OK.
  4. In the active code window, replace the generated code with the following code:
    //repro.c
    //This is from MSDN. It is a sample of the  _popen() function.
    //Use this to verify the handle leak.
    #include "stdafx.h"
    #include "stdio.h"
    #include "stdlib.h"
    
    int main( void )
    {
    int i = 0;
    for (i = 0; i < 10000; i++) {
    char psBuffer[128];
    FILE *pPipe;
    
    /* Run DIR so that it writes its output to a pipe. Open this
    * pipe with the read text attribute so that you can read it 
    * like a text file. 
    */
    if( (pPipe = _popen( "dir *.c /on /p", "rt" )) == NULL )
    exit( 1 );
    
    /* Read the pipe until the end of file. */
    
    while( !feof( pPipe ) ) {
    if( fgets( psBuffer, 128, pPipe ) != NULL )
    printf( psBuffer );
    }
    
    /* Close the pipe and print the return value of the pipe. */
    {
    int result = _pclose( pPipe );
    printf( "\nProcess returned %d\n", result);
    }
    }
    
    return 0;
    }
    
    
  5. On the Build menu, click Build Solution.
  6. On the Debug menu, click Run.
  7. Start Windows Task Manager.
  8. On the Processes tab, view the Handles for your AppName increment.

    Note You may add Handles columns to Windows Task Manager. To do this, follow these steps:
    1. On the View menu, click Select Columns in Windows Task Manager.
    2. Click to select the Handle Count check box, and then click OK.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates


Modification Type:MajorLast Reviewed:4/7/2006
Keywords:kbQFE KBHotfixServer kbvs2002sp1sweep kbtshoot kbfix kbbug KB892473 kbAudDeveloper