Bug #46707 Access Violation in myodbc5.dll
Submitted: 13 Aug 2009 20:58 Modified: 24 Aug 2009 15:12
Reporter: Daniel Kram Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:5.1.5 OS:Windows (XP Pro SP3)
Assigned to: CPU Architecture:Any
Tags: access violation, Delphi, myodbc5

[13 Aug 2009 20:58] Daniel Kram
Description:
I am having occasional issues with access violations, AV, with MySQL ODBC version 5.1
Due to the customer setup, I open and close the connection after every request, update, insert, etc. and have read elsewhere this may cause occasional issues with garbage collection on the MySQL side.
Nevertheless, I am hoping someone has seen this type of error before and has impemented a fix.
All of the machines are on MDAC 2.8, XP Pro SP3
Written Delphi 2007

Any guidance would be helpful.

1001D497  pop     esi
1001D498  xor     eax, eax
1001D49A  pop     ebx
1001D49B  ret
1001D49C  int     3
1001D49D  int     3
1001D49E  int     3
1001D49F  int     3
1001D4A0  mov     ecx, [esp+$04]
1001D4A4  xor     eax, eax
1001D4A6  mov     ax, word ptr [ecx]  ; <-- EXCEPTION
1001D4A9  cmp     ax, $D800
1001D4AD  jb      +$3F
1001D4AF  cmp     ax, $DBFF
1001D4B3  jnbe    +$39
1001D4B5  mov     edx, [esp+$08]
1001D4B9  and     eax, $000003BF      ; ''...
1001D4BE  or      eax, +$40
1001D4C1  shl     eax, $0A
1001D4C4  mov     [edx], eax
1001D4C6  add     ecx, +$02

modules:
xpsp2res.dll Service Pack 2 Messages" Version="5.1.2600.5512
hpmdp5r1.dll hpmdp074.dll" Version="0.3.1537.66
msdasql.dll Microsoft Data Access - OLE DB Provider for ODBC Drivers" Version="2.81.1132.0
odbcint.dll Microsoft Data Access - ODBC Resources" Version="3.525.1132.0
MSDASQLR.DLL Microsoft Data Access - OLE DB Provider for ODBC Drivers Resources" Version="2.81.1132.0
msadcer.dll Microsoft Data Access - OLE DB Cursor Engine Resources" Version="2.81.1132.0
myodbc5.dll MySQL ODBC 5.1 Driver" Version="5.1.5.0
mdnsNSP.dll Bonjour Namespace Provider" Version="1.0.6.2
xpsp3res.dll Service Pack 3 Messages" Version="5.1.2600.5512
msado15.dll Microsoft Data Access - ActiveX Data Objects" Version="2.81.1132.0
uxtheme.dll Microsoft UxTheme Library" Version="6.0.2900.5512
NETAPI32.dll Net Win32 API DLL" Version="5.1.2600.5694
olepro32.dll " Version="5.1.2600.5512
mslbui.dll LangageBar Add In" Version="5.1.2600.5512
MSDATL3.dll Microsoft Data Access - OLE DB Implementation Support Routines" Version="2.81.1132.0
hnetcfg.dll Home Networking Configuration Manager" Version="5.1.2600.5512
mswsock.dll Microsoft Windows Sockets 2.0 Service Provider" Version="5.1.2600.5625
wshtcpip.dll Windows Sockets Helper DLL" Version="5.1.2600.5512
WS2HELP.dll Windows Socket 2.0 Helper for Windows NT" Version="5.1.2600.5512
WS2_32.dll Windows Socket 2.0 32-Bit DLL" Version="5.1.2600.5512
wsock32.dll Windows Socket 32-Bit DLL" Version="5.1.2600.5512
mpr.dll Multiple Provider Router DLL" Version="5.1.2600.5512
winspool.drv Windows Spooler Driver" Version="5.1.2600.5512
oledb32.dll Microsoft Data Access - OLE DB Core Services" Version="2.81.1132.0
RICHED32.DLL Wrapper Dll for Richedit 1.0" Version="5.1.2600.0
msadce.dll Microsoft Data Access - OLE DB Cursor Engine" Version="2.81.3002.0
ODBC32.dll Microsoft Data Access - ODBC Driver Manager" Version="3.525.1132.0
MSCTF.dll MSCTF Server DLL" Version="5.1.2600.5512
oleacc.dll Active Accessibility Core Component" Version="4.2.5406.0
RICHED20.DLL Rich Text Edit Control, v3.0" Version="5.30.23.1230
RESUTILS.DLL Microsoft Cluster Resource Utility DLL" Version="5.1.2600.5512
MTXCLU.DLL MS DTC amd MTS clustering support DLL" Version="2001.12.4414.706
colbact.DLL " Version="2001.12.4414.700
OLEDB32R.DLL Microsoft Data Access - OLE DB Core Services Resources" Version="2.81.1132.0
msctfime.ime Microsoft Text Frame Work Service IME" Version="5.1.2600.5768
MSVCP60.dll Microsoft (R) C++ Runtime Library" Version="6.2.3104.0
msimg32.dll GDIEXT Client DLL" Version="5.1.2600.5512
IMM32.DLL Windows XP IMM32 API Client DLL" Version="5.1.2600.5512
comdlg32.dll Common Dialogs DLL" Version="6.0.2900.5512
MSDART.DLL Microsoft Data Access - OLE DB Runtime Routines" Version="2.81.1132.0
comsvcs.dll " Version="2001.12.4414.702
USERENV.dll Userenv" Version="5.1.2600.5512
winmm.dll MCI API DLL" Version="5.1.2600.5512
PSAPI.DLL Process Status Helper" Version="5.1.2600.5512
CLUSAPI.DLL Cluster API Library" Version="5.1.2600.5512
Iphlpapi.dll IP Helper API" Version="5.1.2600.5512
DNSAPI.dll DNS Client API DLL" Version="5.1.2600.5625
WLDAP32.dll Win32 LDAP API DLL" Version="5.1.2600.5512
winrnr.dll LDAP RnR Provider DLL" Version="5.1.2600.5512
rasadhlp.dll Remote Access AutoDial Helper" Version="5.1.2600.5512
CLBCATQ.DLL " Version="2001.12.4414.700
COMRes.dll " Version="2001.12.4414.700
oleaut32.dll " Version="5.1.2600.5512
comctl32.dll User Experience Controls Library" Version="6.0.2900.5512
ole32.dll Microsoft OLE for Windows" Version="5.1.2600.5512
SETUPAPI.dll Windows Setup API" Version="5.1.2600.5512
Apphelp.dll Application Compatibility Client Library" Version="5.1.2600.5512
version.dll Version Checking and File Installation Libraries" Version="5.1.2600.5512
msvcrt.dll Windows NT CRT DLL" Version="7.0.2600.5512
ADVAPI32.dll Advanced Windows 32 Base API" Version="5.1.2600.5755
RPCRT4.dll Remote Procedure Call Runtime" Version="5.1.2600.5795
GDI32.dll GDI Client DLL" Version="5.1.2600.5698
SHLWAPI.dll Shell Light-weight Utility Library" Version="6.0.2900.5512
Secur32.dll Security Support Provider Interface" Version="5.1.2600.5753
kernel32.dll Windows NT BASE API Client DLL" Version="5.1.2600.5781
ntdll.dll NT Layer DLL" Version="5.1.2600.5755
shell32.dll Windows Shell Common Dll" Version="6.0.2900.5622
oledlg.dll Microsoft Windows(TM) OLE 2.0 User Interface Support" Version="5.1.2600.5512
USER32.dll Windows XP USER API Client DLL" Version="5.1.2600.5512
unidrv.dll Unidrv Printer Driver" Version="0.3.6001.22116
UNIDRVUI.DLL UniDriver User Interface" Version="0.3.6001.221

How to repeat:
It is not readily repeatable, however, does happen about 10 times a week in the 100 terminal shop this application is running.

Sources I have read, including here, have suggested there is some garbage collection not being executed, however, I do not know how to tell MySQL via Delphi or my connection to collect the garbage or when.

I open and close connections at each request. This was at the MySQL DBA at the customer site. For the most part this is not an issue, as I say, it happens about 10 times a week.

Suggested fix:
Can I make a change in Delphi connection object or somewhere else to elliminate?
[13 Aug 2009 20:59] Daniel Kram
Dump from computer

Attachment: forMysql.pdf (application/pdf, text), 64.38 KiB.

[13 Aug 2009 21:01] Daniel Kram
Screen capture of Call Stack

Attachment: forMysql.docx (application/octet-stream, text), 119.24 KiB.

[24 Aug 2009 7:33] Tonci Grgin
Hi Daniel and thanks for your report.

I do not see this as our bug at all.
> Sources I have read, including here, have suggested there is some garbage collection not being executed, however, I do not know how to tell MySQL via Delphi or my connection to collect the garbage or when.

There is no GC in c/ODBC that I know of. My best guess is that you're exhausting ports-related resources in Windows. There can also be an error in your application (see line 3 in attached docx file) or something completely unrelated...

Please, in the future, do not attach things in docx or any other weird format. Plain text should do.
[24 Aug 2009 14:49] Daniel Kram
Tonci, it is quite ironic you state what you do as on 18 August 2009, I received an updated myodbc5.dll, version 5.1.6, and since I have put it in production, all errors have suddenly stopped with zero lines of code change in any of my applications.

There is not any garbage collecting in ODBC, however, there is in MySQL.

Now, I did not inquire as to the fix, just happy the fix fixed my Customers. But, I coded to open/close/build/destroy the connection when it was needed. This was a request of the MySQL DBA on the Customer's end, nevertheless, this open/close repeated process with over 100 terminals seemed to be the issue as the tracing files I attached show - outside of the application into myodbc5.dll.

Anyway, thank you for responding.

And to anyone else having Access Violations in MySQL using 5.1.5 of the myodbc5.dll, drop me a line or post here or ask a helpfuly MySQL developer to send you the 5.1.6 version - it appears to be working for me.
[24 Aug 2009 15:12] Tonci Grgin
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Explanation: Daniel, excellent! Fixed in c/ODBC 5.1.6.
[15 Jan 2010 9:32] Lukasz Hlebowicz
I have the same error. I am installing 5.1.6 version of drivers now and I hope it will be a solution. This post was helpful. Thanks guys.