Microsoft KB Archive/818493

= FIX: ODBCCR32 Deadlock Occurs When You Use MFC and NT Critical Sections =

Article ID: 818493

Article Last Modified on 4/7/2006

-

APPLIES TO


 * Microsoft Data Access Components 2.7 Service Pack 1

-



SYMPTOMS
If you use the MFC (Microsoft Foundation Classes) ODBC wrapper classes (for example, CDatabase and CRecordset) on one thread, and you use straight ODBC API calls on another thread in the same process, a deadlock may occur.



RESOLUTION
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 service pack that contains this hotfix.

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 about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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. The English version of this fix has the file attributes (or later) 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 --  18-Apr-2003  23:28  3.520.9031.42 204,800  Odbc32.dll 21-Apr-2003 23:11  6.0.2800.1106 194,048  Q818493_mdac27_x86.exe



WORKAROUND
To work around this problem, do not use the ODBC cursor library in your code. To avoid loading the ODBC cursor library when you use the MFC ODBC CDatabase class, pass false for the bUseCursorLib parameter when you call CDatabase::Open.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section of this article.



MORE INFORMATION
When the deadlock occurs, you see the following two stacks:   1  Id: cfc.100 Suspend: 1 Teb: 7ffdd000 Unfrozen ChildEBP RetAddr 00baeb00 77f5d64e ntdll!NtWaitForSingleObject+0xc 00baeb3c 77f42044 ntdll!RtlpWaitForCriticalSection+0x126 00baeb44 73daf4db ntdll!RtlEnterCriticalSection+0x46 00baeb58 73db0ecc MFC42!AfxLockGlobals+0x65 00baeb7c 73db45b9 MFC42!CDynLinkLibrary::CDynLinkLibrary+0x63 00baeb9c 00f29332 MFC42!AfxCoreInitModule+0x2c 00baebb8 00f29709 ODBCCR32!DllMain+0x1c 00baebd8 77f47dc9 ODBCCR32!_DllMainCRTStartup+0x50 00baebf8 77f54401 ntdll!LdrpCallInitRoutine+0x14 00baecf8 77f5286e ntdll!LdrpRunInitializeRoutines+0x34e 00baef70 77f52a9e ntdll!LdrpLoadDll+0x2fe 00baf1d8 77e48404 ntdll!LdrLoadDll+0x133 00baf240 77e48505 kernel32!LoadLibraryExW+0x1af 00baf250 0032f340 kernel32!LoadLibraryExA+0x1d 00baf374 00324dcd ODBC32!LoadCursorLibrary+0x1c6 00baf3c0 00321c46 ODBC32!FinishConnection+0x6e 00baf3e8 003218cb ODBC32!SQLInternalDriverConnectW+0x17a 00bafb2c 0034d651 ODBC32!SQLDriverConnectW+0x6ba 00bafb68 004015ce ODBC32!SQLDriverConnect+0xb1

2 Id: cfc.edc Suspend: 1 Teb: 7ffdc000 Unfrozen ChildEBP RetAddr 00cafe3c 77f5d64e ntdll!NtWaitForSingleObject+0xc 00cafe78 77f42044 ntdll!RtlpWaitForCriticalSection+0x126 00cafe80 77f5326d ntdll!RtlEnterCriticalSection+0x46 00caff84 77e42e83 ntdll!LdrUnloadDll+0x35 00caff94 73da41e9 kernel32!FreeLibrary+0x3b 00caffa0 004016cb MFC42!AfxFreeLibrary+0x12

Keywords: kbbug kbfix kbqfe kbhotfixserver KB818493

-

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

© Microsoft Corporation. All rights reserved.