Bug #115710 | Access violation writing location 0x0000000000000320 while opening connection | ||
---|---|---|---|
Submitted: | 29 Jul 5:30 | Modified: | 12 Aug 19:29 |
Reporter: | Hennadii Niemtsov | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / ODBC | Severity: | S3 (Non-critical) |
Version: | 9.0.0.0 | OS: | Windows (Windows 10 Enterprise Version:10.0.19045) |
Assigned to: | CPU Architecture: | Other (AMD64) | |
Tags: | access violation |
[29 Jul 5:30]
Hennadii Niemtsov
[29 Jul 5:53]
Hennadii Niemtsov
VS2022 C++ project file to reproduce issue
Attachment: TestMySqlOdbc.zip (application/x-zip-compressed, text), 4.88 KiB.
[29 Jul 5:55]
Hennadii Niemtsov
generated dump file
Attachment: TestMySqlOdbc_DMP.zip (application/x-zip-compressed, text), 15.16 MiB.
[30 Jul 4:22]
MySQL Verification Team
Hello Hennadii Niemtsov, Thank you for the bug report. Verified as described. Regards, Ashwini Patil
[2 Aug 4:02]
Hennadii Niemtsov
I found conditions when mysql_init() returns null. Here is explanation a little verbally so check attached PNG image for clarity. Here is what i found: Initially variables: mysql_client_init and my_thread_global_init_done are set to FALSE. Both threads are executing `mysql_server_init()`, but the first thread is the one that checks the state of `mysql_client_init` and changes it from `FALSE` to `TRUE`. As a result, the second thread follows a different execution path. If the second thread reads the `my_thread_global_init_done` variable before the first thread has set it to `TRUE`, the second thread will return a null pointer from `mysql_init()`.
[2 Aug 4:03]
Hennadii Niemtsov
when mysql_init() returns null
Attachment: nullptr.png (image/png, text), 38.78 KiB.
[12 Aug 9:41]
Bogdan Degtyariov
Posted by developer: The issue happened because of concurrent calls to mysql_init() that called mysql_library_init() simultaneously. It was not thread safe The patch makes sure mysql_library_init() is called before any mysql_init() calls. This makes mysql_init() thread safe. Changes are pushed in the source tree.
[12 Aug 19:29]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Connector/ODBC 9.1.0 release, and here's the proposed changelog entry from the documentation team: The internal mysql_init() method used for making connections is now thread safe. Thank you for the bug report.