The CreateRemoteThread API May Leak a Handle

ID: Q246691


The information in this article applies to:
  • Microsoft Windows NT Server versions 4.0, 4.0 SP4, 4.0 SP5, 4.0 SP6
  • Microsoft Windows NT Server, Enterprise Edition versions 4.0, 4.0 SP4, 4.0 SP5, 4.0 SP6
  • Microsoft Windows NT Workstation versions 4.0, 4.0 SP4, 4.0 SP5, 4.0 SP6


SYMPTOMS

The CreateRemoteThread application programming interface (API) may leak a handle when it is unsuccessful and return a null handle. This increases a handle count of the process that calls the CreateRemoteThread function. Because the handle is null, the calling process cannot close the handle, which results in a memory leak.

NOTE: To detect the handle leak, use Performance Monitor and monitor the Handle Count for the process that calls the CreateRemoteThread API.


CAUSE

The CreateRemoteThread function first successfully creates a thread where it creates a thread handle. If the function is unsuccessful in the later stages of processing, the created thread is terminated and the open handle to this thread is not closed. This open handle causes a memory leak.


RESOLUTION

A supported fix that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next Windows NT 4.0 service pack that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The English version of this fix should have the following file attributes or later:

   Date      Time      Size      File name      Platform
   -----------------------------------------------------
   11/18/99  06:19pm   375,056   Kernel32.dll   Intel
   11/18/99  06:17pm   589,584   Kernel32.dll   Alpha 


STATUS

Microsoft has confirmed this to be a problem in Windows NT 4.0.

Additional query words:

Keywords : kbenv
Version : winnt:4.0,4.0 SP4,4.0 SP5,4.0 SP6
Platform : winnt
Issue type : kbbug


Last Reviewed: November 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.