FIX: The CoUninitialize function is not thread-safe in a multithreaded environment (331260)



The information in this article applies to:

  • Microsoft COM+ 1.0, when used with:
    • the operating system: Microsoft Windows 2000

This article was previously published under Q331260

SYMPTOMS

When one Microsoft Component Object Model (COM) DLL (DLL A) has a global variable references COM object in another COM DLL (DLL B), if these two DLLs are loaded and then unloaded in a multithreaded fashion, an access violation may occur.

CAUSE

When the last COM apartment in a process calls the CoUninitialize function, all DLLs that are loaded by COM will be unloaded. An access violation will occur if the following events occur:
  1. COM unloads DLL B.
  2. While COM unloads DLL A, a new thread/apartment is started that references the global variable in DLL A.
  3. The global variable in DLL A references an address in the unloaded DLL B that is no longer valid.

RESOLUTION

How to Obtain the Hotfix

This issue is fixed in the Microsoft Windows 2000 Server COM+ 1.0 Hotfix Package 24. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

810578 Availability of Windows 2000 Post-Service Pack 3 COM+ Hotfix Rollup Package 24

STATUS

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

Modification Type:MinorLast Reviewed:11/8/2004
Keywords:kbWin2000preSP5fix kbbug kbfix kbQFE kbWin2000preSP4Fix KB331260 kbAudDeveloper