Microsoft KB Archive/889318

= A resource that is shared by two threads through a named mutex object is not shared as expected in Windows Server 2003 =

Article ID: 889318

Article Last Modified on 1/9/2007

-

APPLIES TO


 * Microsoft Windows Server 2003, Web Edition
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition for Itanium-based Systems
 * Microsoft Windows Server 2003, Datacenter Edition for Itanium-Based Systems
 * Microsoft Windows Server 2003 Service Pack 1

-





SYMPTOMS
In Microsoft Windows Server 2003, a resource that is being shared by two threads through a named mutex object is not shared as expected. A second named mutex object is created instead, and both the original named mutex object and the new named mutex object use the same resource. This issue may occur when the following conditions are true:
 * A named mutex object is opened and closed repeatedly.
 * The named mutex object has the same name every time that it is opened.



CAUSE
This issue occurs when the following conditions are true:
 * Two or more threads repeatedly open and close a named mutex object.
 * Two or more threads open and close a named mutex object at the same time.
 * Two or more threads each open and close a named mutex object that has the same name.

When all these conditions are true, the information about the named mutex object may be mismatched in the object-management process.

Note This issue is more likely to occur on a multiprocessor computer.

This issue occurs if a program uses the following procedure to open or to create a named mutex object:
 * 1) The program calls the OpenMutex function to open the named mutex object.
 * 2) If the OpenMutex function does not run correctly and if the return code is NULL, the program operates as if the named mutex object does not exist.
 * 3) Because the program operates as if the named mutex object does not exist, the program calls the CreateMutex function.
 * 4) The named mutex object is created.



WORKAROUND
To work around this issue, call the CreateMutex function instead of the OpenMutex function. If the named mutex object does not exist, the CreateMutex function creates a new named mutex object. However, if the named mutex object does exist, the CreateMutex function returns a handle to the named mutex object.

Typically, the Initialize function of a program creates a named mutex object that has the same name every time that the named mutex object is created. This named mutex object is closed when the program ends. Therefore, if your program must repeatedly open, create, and then close a named mutex object, use the CreateMutex function instead of the OpenMutex function.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section. This problem is fixed in Windows Server 2003 Service Pack 2 (SP2).

Keywords: kbtshoot kbprb KB889318

-

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

© Microsoft Corporation. All rights reserved.