Bug #117377 ODBC Connector > 9.0.0 causes RStudio session to crash
Submitted: 3 Feb 20:00 Modified: 10 Feb 12:07
Reporter: Matthew Williamson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:9.0.2 OS:Windows (Windows 11)
Assigned to: CPU Architecture:Any

[3 Feb 20:00] Matthew Williamson
Description:
When using MySQL ODBC driver versions 9.1 or 9.2 within RStudio, any attempt to establish an ODBC connection to a MySQL database results in an immediate crash of the R session. The connection works fine in a standalone R console and in other applications that I have tested so for. This may be specific to RStudio.

Same behavior occurs on 30+ computers that I have encountered.  

The exact error in RStudio is "R Session Aborted. R encountered a fatal error. The session was terminated"

reverting to any 8.x.x. ODBC connector resolves issue, however for security purposes my organization needs to update these drivers. 

No ODBC or RStudio logs provide insight. R crash reports point to Visual C++

R: 4.4.0
RStudio: 2024.12.0
MS Visual C++ (x64): 14.42.34433.0

All are 64 bit applications. Multiple uninstall/reinstall of all involved pieces (ODBC Driver, C++, R, RStudio) in various orders and with restarts consistently. 

Crash Report Excerpt pointing to an issue with C++. version stated in this crash report is NOT the version of C++ installed. Unsure why it states that older version. 

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ffde3b03080 (MSVCP140!mtx_do_lock+0x0000000000000074)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 0000000000000000
   Parameter[1]: 0000000000000000
Attempt to read from address 0000000000000000

PROCESS_NAME:  rsession-utf8.exe

READ_ADDRESS:  0000000000000000 

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.

EXCEPTION_CODE_STR:  c0000005

EXCEPTION_PARAMETER1:  0000000000000000

EXCEPTION_PARAMETER2:  0000000000000000

STACK_TEXT:  
000000fa`f85f5500 00007ffd`a9ece544     : 000002c7`39bfab60 00000000`00000000 00007ffd`aa778df0 00000000`00000000 : MSVCP140!mtx_do_lock+0x74
000000fa`f85f5560 000002c7`39bfab60     : 00000000`00000000 00007ffd`aa778df0 00000000`00000000 000002c7`39bfabf8 : myodbc9w+0x3e544
000000fa`f85f5568 00000000`00000000     : 00007ffd`aa778df0 00000000`00000000 000002c7`39bfabf8 000002c7`39bfab88 : 0x000002c7`39bfab60

STACK_COMMAND:  ~0s; .ecxr ; kb

FAULTING_SOURCE_LINE:  D:\a\_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp

FAULTING_SOURCE_FILE:  D:\a\_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp

FAULTING_SOURCE_LINE_NUMBER:  103

FAULTING_SOURCE_CODE:  
No source found for 'D:\a\_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp'

SYMBOL_NAME:  MSVCP140!mtx_do_lock+74

MODULE_NAME: MSVCP140

IMAGE_NAME:  MSVCP140.dll

FAILURE_BUCKET_ID:  NULL_POINTER_READ_c0000005_MSVCP140.dll!mtx_do_lock

OSPLATFORM_TYPE:  x64

OSNAME:  Windows 10

IMAGE_VERSION:  14.29.30153.0

FAILURE_ID_HASH:  {f7938165-b4af-ccbf-11b4-f442616c9ba8}

How to repeat:
1. Configure ODBC Connector DSN
2 .Open RStudio and attempt to establish an ODBC connection to a MySQL database using the 9.1/9.2 MySQL ODBC driver.
3. The R session crashes immediately with an access violation error.
[4 Feb 19:10] Matthew Williamson
You can close this request. After further investigation the problem is the same known Visual C++ >14.42 incompatibility. 

I should have deduced this based on the limitation to a single application. 

RStudio install includes copies of a multiple msvcp140.dll files within its bin folder.  Instead of reaching out to the system installed .dll for Visual c++ it uses its own copies. The copies installed with the most recent version of RStudio are not up to date (Version 14.29) and have a known incompatibility with  the ODBC Connection >9.0.0.  Most recent version of RStudio still uses the old .dll and updating C++ does not modify the RStudio copies. 

In the event that this is helpful to anyone the immediate resolution is to ensure Visual C++ Redistributable package 2015-2022 is updated a version higher than >14.36 Then copy all msvcp140***.dll files from C:\Windows\System32 to C:\Program Files\RStudio\resources\app\bin and overwrite the msvcp140***.dlls that currently exist in that location.
[10 Feb 12:07] MySQL Verification Team
Thank you Mr. Williamson.

When you report a bug, next time, please include also a fully repeatable test case.

Thanks again.