FIX: Application leaks a handle when you call the CRT _popen function in Visual C++ .NET 2003

This article has been archived. It is offered "as is" and will no longer be updated.
When you use the C run-time (CRT) _popen function in Microsoft Visual C++ .NET 2003, your application leaks a handle every time that you call the function.
To help improve performance, the implementation for the CRT _popen function was changed in Visual C++ .NET 2003. The CRT _popen function now uses the WinAPI CreateProcess function instead of the CRT _spawnl function. The handle leak is caused by a bug in Visual C++ .NET 2003. This bug causes the hThread handle field of the PROCESS_INFORMATION structure to stay open.
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 .NET 2003 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.


No prerequisites are required.

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.

File information

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   --------------------------------------------------------------   03-Feb-2005  02:57                     13,858  A_map.c   03-Feb-2005  03:27                    363,744  Eh.lib   03-Feb-2005  02:57                     10,456  Io.h   06-Feb-2004  19:29                      4,246  Ios.cpp   03-Feb-2005  03:30                  2,707,628  Libc.lib   03-Feb-2005  03:34                  3,023,492  Libcd.lib   03-Feb-2005  03:31                  2,937,528  Libcmt.lib   03-Feb-2005  03:36                  3,304,810  Libcmtd.lib   03-Feb-2005  03:30                  3,601,372  Libcp.lib   03-Feb-2005  03:35                  4,433,774  Libcpd.lib   03-Feb-2005  03:32                  3,651,664  Libcpmt.lib   03-Feb-2005  03:36                  4,449,888  Libcpmtd.lib   03-Feb-2005  04:11  7.10.4353.0       499,712  Msvcp71.dll         03-Feb-2005  03:37  7.10.4353.0       765,952  Msvcp71d.dll        03-Feb-2005  04:11  7.10.4353.0       348,160  Msvcr71.dll         03-Feb-2005  03:37  7.10.4353.0       544,768  Msvcr71d.dll        03-Feb-2005  02:58                     17,400  Popen.c   03-Feb-2005  02:57                      9,948  Read.c   03-Feb-2005  16:00                    202,240  Vc_user_crt71_rtl_x86_---.msm   03-Feb-2005  16:00                    151,040  Vc_user_stl71_rtl_x86_---.msm
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
To verify that your application has a handle leak, monitor the Handles count in Windows Task Manager.

For example, when you build and then run the following Visual C++ Win32 Console project code, the Handles count will continue to increase in Windows Task Manager:
// Testpopen.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <stdio.h>#include <conio.h>int _tmain(int argc, _TCHAR* argv[]){	FILE * pPipe = NULL;	char	buffer[128] = {0};	while (!kbhit())	{		pPipe = _popen("dir *.* /s", "r");		if (pPipe != NULL)		{			printf(_T("Pipe opened at 0x%08x\n"), (unsigned long)pPipe);			while (!feof(pPipe))			{				if (fgets(buffer, 128, pPipe))					printf(buffer);			}			printf("Pipe closed (%d)\n", _pclose(pPipe));					}	}		return 0;}
For additional 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
Visual Studio Update QFE 3432

Article ID: 892086 - Last Review: 12/09/2015 02:02:03 - Revision: 2.2

Microsoft Visual C++ .NET 2003 Standard Edition, Microsoft Visual Studio .NET 2003 Professional Edition, Microsoft Visual Studio .NET 2003 Enterprise Developer, Microsoft Visual Studio .NET 2003 Enterprise Architect, Microsoft Visual Studio .NET 2003 Academic Edition

  • kbnosurvey kbarchive kbqfe kbbug kbfix kbprb kbhotfixserver KB892086