MATLAB: MATLAB crashes when using MySQL ODBC 8.x drivers

Database Toolbox

When connecting to any MySQL Database using ODBC Driver 8.x, MATLAB crashes.
>>conn = database('MySQL_DS','dta','dtarocks')
>>curs = exec(conn,'SELECT * FROM productTable');
>>close(conn)
MATLAB Crashes with following Crash dump:
Crash Log:
——————————————————————————–
Access violation detected at Wed May 02 10:39:15 2018 -0400
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel® HD Graphics 620 Version 22.20.16.4815 (2017-9-26)
Java Version : Java 1.8.0_144-b01 with Oracle Corporation Java HotSpot™ 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 2965112
MATLAB Root : C:\Program Files\MATLAB\R2018a
MATLAB Version : 9.4.0.813654 (R2018a)
OpenGL : hardware
Operating System : Microsoft Windows 10 Pro
Process ID : 14236
Processor ID : x86 Family 6 Model 142 Stepping 9, GenuineIntel
Session Key : e14397ef-7890-480a-a027-54d814f85e2a
Window System : Version 10.0 (Build 16299)
Fault Count: 1
Abnormal termination
Register State (from fault):
RAX = 0000000000000000 RBX = 0000000000000180
RCX = 0000000000000005 RDX = 0000000000000000
RSP = 00000000043f9600 RBP = 0000000000000005
RSI = 00007ff8d585c510 RDI = 0000000000000005
R8 = 00007ff8d585c510 R9 = 00000000000001db
R10 = 00000000ff295020 R11 = 00000000043f9600
R12 = 0000000000000000 R13 = 00000000e1a77460
R14 = 000000000000000b R15 = 00000000d596df00
RIP = 00007ff8ac5d1fcc EFL = 00010246
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00007ff8ac5d1fcc C:\Program Files\MySQL\Connector ODBC 8.0\myodbc8a.dll+00401356 SQLDescribeParam+00388880
[ 1] 0x00007ff8b56f2180 C:\Program Files\MATLAB\R2018a\bin\win64\LIBEAY32.dll+00008576 CRYPTO_lock+00000160
[ 2] 0x00007ff8d583e4e5 C:\Program Files\MATLAB\R2018a\bin\win64\SSLEAY32.dll+00189669 SSL_COMP_set0_compression_methods+00000517
[ 3] 0x00007ff8d583e2c2 C:\Program Files\MATLAB\R2018a\bin\win64\SSLEAY32.dll+00189122 SSL_COMP_get_compression_methods+00000018
[ 4] 0x00007ff8d584568c C:\Program Files\MATLAB\R2018a\bin\win64\SSLEAY32.dll+00218764 SSL_library_init+00000524
[ 5] 0x00007ff8ac5d2569 C:\Program Files\MySQL\Connector ODBC 8.0\myodbc8a.dll+00402793 SQLDescribeParam+00390317
[ 6] 0x00007ff8ac5b907f C:\Program Files\MySQL\Connector ODBC 8.0\myodbc8a.dll+00299135 SQLDescribeParam+00286659
[ 7] 0x00007ff8ac5ae775 C:\Program Files\MySQL\Connector ODBC 8.0\myodbc8a.dll+00255861 SQLDescribeParam+00243385
[ 8] 0x00007ff8ac57db95 C:\Program Files\MySQL\Connector ODBC 8.0\myodbc8a.dll+00056213 SQLDescribeParam+00043737
[ 9] 0x00007ff8ac57d230 C:\Program Files\MySQL\Connector ODBC 8.0\myodbc8a.dll+00053808 SQLDescribeParam+00041332
[ 10] 0x00007ff8ac59e349 C:\Program Files\MySQL\Connector ODBC 8.0\myodbc8a.dll+00189257 SQLDescribeParam+00176781
[ 11] 0x00007ff8b427e314 C:\WINDOWS\SYSTEM32\ODBC32.dll+00320276 SQLTransact+00003668
[ 12] 0x00007ff8b4264a53 C:\WINDOWS\SYSTEM32\ODBC32.dll+00215635 SQLConnectW+00003523
[ 13] 0x00007ff8b426467e C:\WINDOWS\SYSTEM32\ODBC32.dll+00214654 SQLConnectW+00002542
[ 14] 0x00007ff8b4296013 C:\WINDOWS\SYSTEM32\ODBC32.dll+00417811 SQLConnect+00000499
[ 15] 0x0000000045244aa7 bin\win64\dodbc.dll+00084647
[ 16] 0x00000000452466eb bin\win64\dodbc.dll+00091883
[ 17] 0x000000003018ab0d bin\win64\pgo\mcos_impl.dll+00502541
[ 18] 0x000000003018a3f8 bin\win64\pgo\mcos_impl.dll+00500728
[ 19] 0x0000000030189e1b bin\win64\pgo\mcos_impl.dll+00499227
[ 20] 0x000000003018622e bin\win64\pgo\mcos_impl.dll+00483886
[ 21] 0x00000000301c1834 bin\win64\pgo\mcos_impl.dll+00727092
[ 22] 0x0000000030335775 bin\win64\pgo\mcos_impl.dll+02250613 QueryMLFcnTable_mcos_impl+01483845
[ 23] 0x000000003033ea59 bin\win64\pgo\mcos_impl.dll+02288217 QueryMLFcnTable_mcos_impl+01521449
[ 24] 0x000000001c3cf1e5 bin\win64\mcos.dll+00127461 omDirectCallMethod+00000069
[ 25] 0x00000000200e493e bin\win64\pgo\libmwlxeindexing.dll+00346430 MathWorks::lxe::MatrixModuleImplementation::SetHeterogeneousArray+00012822
[ 26] 0x000000002016888f bin\win64\pgo\libmwlxeindexing.dll+00886927 MathWorks::lxe::assign_paren_shared_xvalue_ptr_uninitialized_to_struct+00006091
[ 27] 0x0000000020096684 bin\win64\pgo\libmwlxeindexing.dll+00026244 MathWorks::lxe::at_paren_pointer+00001108
[ 28] 0x0000000020096684 bin\win64\pgo\libmwlxeindexing.dll+00026244 MathWorks::lxe::at_paren_pointer+00001108
[ 29] 0x00000000200f9df8 bin\win64\pgo\libmwlxeindexing.dll+00433656 MathWorks::lxe::DereferenceRplaceToXvalueZeroOutputs+00000040
[ 30] 0x00000000200d8511 bin\win64\pgo\libmwlxeindexing.dll+00296209 MathWorks::lxe::at_rparen0+00000257
[ 31] 0x000000001efdb44e bin\win64\pgo\m_lxe.dll+27898958 mwboost::archive::detail::pointer_oserializer<mwboost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00426686
[ 32] 0x000000001d62a808 bin\win64\pgo\m_lxe.dll+00960520 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00121832
[ 33] 0x000000001d62b403 bin\win64\pgo\m_lxe.dll+00963587 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00124899
[ 34] 0x000000001d62c836 bin\win64\pgo\m_lxe.dll+00968758 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00130070
[ 35] 0x000000001d62d3f0 bin\win64\pgo\m_lxe.dll+00971760 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00133072
[ 36] 0x000000001d62c97f bin\win64\pgo\m_lxe.dll+00969087 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00130399
[ 37] 0x000000001d62ca7e bin\win64\pgo\m_lxe.dll+00969342 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00130654
[ 38] 0x000000001d5ae8a5 bin\win64\pgo\m_lxe.dll+00452773
[ 39] 0x000000001d5ab335 bin\win64\pgo\m_lxe.dll+00439093
[ 40] 0x000000001d5aa82e bin\win64\pgo\m_lxe.dll+00436270
[ 41] 0x000000001d5a8b35 bin\win64\pgo\m_lxe.dll+00428853
[ 42] 0x000000001d5a8e9e bin\win64\pgo\m_lxe.dll+00429726
[ 43] 0x000000001d5a8e29 bin\win64\pgo\m_lxe.dll+00429609
[ 44] 0x000000001c60c51a bin\win64\pgo\m_dispatcher.dll+00050458 Mfh_file::dispatch_fh_impl+00001114
[ 45] 0x000000001c60c0b2 bin\win64\pgo\m_dispatcher.dll+00049330 Mfh_file::dispatch_fh+00000062
[ 46] 0x000000001c604674 bin\win64\pgo\m_dispatcher.dll+00018036 Mfunction_handle::dispatch+00000420
[ 47] 0x000000001d5a2aa1 bin\win64\pgo\m_lxe.dll+00404129
[ 48] 0x000000001d628e25 bin\win64\pgo\m_lxe.dll+00953893 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00115205
[ 49] 0x000000001d62a808 bin\win64\pgo\m_lxe.dll+00960520 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00121832
[ 50] 0x000000001d62b403 bin\win64\pgo\m_lxe.dll+00963587 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00124899
[ 51] 0x000000001d62c836 bin\win64\pgo\m_lxe.dll+00968758 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00130070
[ 52] 0x000000001d62d3f0 bin\win64\pgo\m_lxe.dll+00971760 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00133072
[ 53] 0x000000001d62c97f bin\win64\pgo\m_lxe.dll+00969087 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00130399
[ 54] 0x000000001d62ca7e bin\win64\pgo\m_lxe.dll+00969342 mwboost::serialization::singleton<mwboost::archive::detail::pointer_iserializer<mwboost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00130654
[ 55] 0x000000001d5ae8a5 bin\win64\pgo\m_lxe.dll+00452773
[ 56] 0x000000001d5ab335 bin\win64\pgo\m_lxe.dll+00439093
[ 57] 0x000000001d5aa82e bin\win64\pgo\m_lxe.dll+00436270
[ 58] 0x000000001d5b1b9a bin\win64\pgo\m_lxe.dll+00465818
[ 59] 0x000000001d5b133d bin\win64\pgo\m_lxe.dll+00463677
[ 60] 0x000000001d5b144e bin\win64\pgo\m_lxe.dll+00463950
[ 61] 0x000000001d751d9c bin\win64\pgo\m_lxe.dll+02170268 mwboost::serialization::singleton<mwboost::archive::detail::pointer_oserializer<mwboost::archive::binary_oarchive,MathWorks::lxe::PreLineExecutionEvent> >::get_instance+00475644
[ 62] 0x000000001d751d4a bin\win64\pgo\m_lxe.dll+02170186 mwboost::serialization::singleton<mwboost::archive::detail::pointer_oserializer<mwboost::archive::binary_oarchive,MathWorks::lxe::PreLineExecutionEvent> >::get_instance+00475562
[ 63] 0x000000001d58051d bin\win64\pgo\m_lxe.dll+00263453
[ 64] 0x000000001d1d8acf bin\win64\pgo\m_interpreter.dll+00297679 inEvalCmdWithLocalReturn+00000063
[ 65] 0x00000000fb60bedb bin\win64\libmwbridge.dll+00114395 mnParser+00001595
[ 66] 0x000000001c466564 bin\win64\mcr.dll+00222564 mcr::runtime::setInterpreterThreadSingletonToCurrent+00091332
[ 67] 0x000000001c4697ae bin\win64\mcr.dll+00235438 mcr::runtime::setInterpreterThreadSingletonToCurrent+00104206
[ 68] 0x000000001c486c8a bin\win64\mcr.dll+00355466 mcrRegisterExternalFunction+00007930
[ 69] 0x000000001c4889bc bin\win64\mcr.dll+00362940 mcrRegisterExternalFunction+00015404
[ 70] 0x000000001c485bff bin\win64\mcr.dll+00351231 mcrRegisterExternalFunction+00003695
[ 71] 0x000000001c486c46 bin\win64\mcr.dll+00355398 mcrRegisterExternalFunction+00007862
[ 72] 0x000000001c485ce3 bin\win64\mcr.dll+00351459 mcrRegisterExternalFunction+00003923
[ 73] 0x000000001c488ff6 bin\win64\mcr.dll+00364534 mcrRegisterExternalFunction+00016998
[ 74] 0x00000000fd014f67 bin\win64\iqm.dll+00544615 iqm::IqmPlugin<cmddistributor::PackagedTaskIIP>::getIIP+00016215
[ 75] 0x00000000fd01567f bin\win64\iqm.dll+00546431 iqm::PackagedTaskPlugin::execute+00000911
[ 76] 0x00000000fd014fed bin\win64\iqm.dll+00544749 iqm::IqmPlugin<cmddistributor::PackagedTaskIIP>::getIIP+00016349
[ 77] 0x00000000fd0154c3 bin\win64\iqm.dll+00545987 iqm::PackagedTaskPlugin::execute+00000467
[ 78] 0x00000000fcfed9ea bin\win64\iqm.dll+00383466 iqm::Iqm::setupIqmFcnPtrs+00071994
[ 79] 0x00000000fcfed84c bin\win64\iqm.dll+00383052 iqm::Iqm::setupIqmFcnPtrs+00071580
[ 80] 0x00000000fcfce722 bin\win64\iqm.dll+00255778 iqm::Iqm::deliver+00003730
[ 81] 0x00000000fcfcf749 bin\win64\iqm.dll+00259913 iqm::Iqm::deliver+00007865
[ 82] 0x00000001001aa211 bin\win64\libmwservices.dll+01810961 services::system_events::PpeDispatchHook::dispatchOne+00030865
[ 83] 0x00000001001b7ff3 bin\win64\libmwservices.dll+01867763 sysq::addProcessPendingEventsUnitTestHook+00004659
[ 84] 0x00000001001b81e0 bin\win64\libmwservices.dll+01868256 sysq::addProcessPendingEventsUnitTestHook+00005152
[ 85] 0x00000001001b9576 bin\win64\libmwservices.dll+01873270 sysq::getCondition+00003446
[ 86] 0x00000001001bb0e6 bin\win64\libmwservices.dll+01880294 svWS_ProcessPendingEvents+00000230
[ 87] 0x000000001c470737 bin\win64\mcr.dll+00263991 mcr::runtime::setInterpreterThreadSingletonToCurrent+00132759
[ 88] 0x000000001c472360 bin\win64\mcr.dll+00271200 mcr::runtime::setInterpreterThreadSingletonToCurrent+00139968
[ 89] 0x000000001c44e9b7 bin\win64\mcr.dll+00125367 mcr_process_events+00001959
[ 90] 0x000000001c31fef5 bin\win64\MVMLocal.dll+00327413 mvm_server::inproc::LocalFactory::terminate+00139589
[ 91] 0x00000000fa9605b9 bin\win64\mvm.dll+01246649 mvm::detail::initLocalMvmHack+00000793
[ 92] 0x00000000fa960dcb bin\win64\mvm.dll+01248715 mvm::detail::SessionImpl::privateSession+00000555
[ 93] 0x00000000fa960ff1 bin\win64\mvm.dll+01249265 mvm::detail::SessionImpl::privateSession+00001105
[ 94] 0x000000014000780d bin\win64\MATLAB.exe+00030733
[ 95] 0x000000014000862f bin\win64\MATLAB.exe+00034351
[ 96] 0x00007ff8df441fe4 C:\WINDOWS\System32\KERNEL32.DLL+00073700 BaseThreadInitThunk+00000020
[ 97] 0x00007ff8e191f061 C:\WINDOWS\SYSTEM32\ntdll.dll+00454753 RtlUserThreadStart+00000033

Best Answer

This is a known incompatibility issue with the MySQL ODBC 8.x drivers.
Please use below workarounds to resolve the issue:
1. MySQL ODBC Connector versions other than 8.0.x(e.g. ODBC 5.3) can be used to resolve the issue
2. JDBC drivers can be used to resolve the issue.