FIX: Deadlock in OLE DB Session Pooling in an STA COM Object

Article translations Article translations
Article ID: 259753 - View products that this article applies to.
This article was previously published under Q259753
Expand all | Collapse all

On This Page


When you use OLE DB session pooling from a single threaded apartment (STA) COM object on a Windows NT 4.0 computer, STA COM object method re-entrancy may cause a deadlock in the OLE DB synchronization code.


To resolve this problem, obtain the latest service pack for Microsoft Data Access Components 2.6. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
300635 INFO: How to Obtain the Latest MDAC 2.6 Service Pack


The English version of this fix should have the following file attributes or later:
   Date         Time    Version       Size      File name     Platform
   12/06/2000   19:41   2.60.7006.0   459,024   Oledb32.dll   x86 
This fix does not contain a Hotfix.exe installer. A Readme.txt file is included which details the installation procedure. This fix should not require a restart in order to be installed.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in Microsoft Data Access Components 2.6 Service Pack 1 and MDAC 2.7.


Method calls to an STA COM object can be re-entered on the same thread, in much the same way as a recursive function call (where the same thread of execution can re-enter the same function). For example, if you peek at the Windows message loop by using the Win32 API call PeekMessage inside an STA COM object method, this can cause a second pending method call to re-enter the same STA COM object method on the same thread of execution. This is the design of STA COM objects and is not a bug. Under normal circumstances, this does not cause a deadlock, and both method calls execute normally.

In this specific case, the OLE DB code internally calls the Win32 API function CoCreateInstance to instantiate an internally used COM object. In certain circumstances, this can trigger STA COM object method call re-entrancy on Windows NT 4.0. In this particular case, a deadlock occurs in the OLE DB code because OLE DB obtains an internal lock while processing the first method call and then triggers STA re-entrancy while this lock is held. The original lock held by the first method call blocks the same thread inside of the second method call from obtaining another dependent lock in the OLE DB code. Because the first lock is held by the same thread, this lock will never be released, and this blocks other threads in the same process from using OLE DB.

The occurrence of this deadlock is rare because it requires a specific series of events to occur at precisely the same time. To determine if this specific problem has occurred, attach a debugger to the process and look for a call stack that enters some COM method X, then enters OLE DB code, then re-enters the same method X further up the stack, and then goes back into OLE DB code. The top of the stack of the deadlocked thread will contain the following function calls:
OLE DB32!TCMHashTableLocked<unsigned short const *,CUdlCacheValue *>__ReaderLock+0x85 


For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
300634 INFO: List of Bugs Fixed in MDAC 2.6 Service Pack 1
300635 INFO: How to Obtain the Latest MDAC 2.6 Service Pack


Article ID: 259753 - Last Review: April 7, 2006 - Revision: 2.1
  • Microsoft OLE DB 2.1, when used with:
    • Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000
  • Microsoft OLE DB 2.5, when used with:
    • Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000
  • Microsoft OLE DB 2.6, when used with:
    • Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000
kbqfe kbhotfixserver kbbug kbdatabase kbfix KB259753

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from