Opened 9 years ago
Closed 9 years ago
#5528 closed defect (fixed)
MySQL driver crash if used from a thread
Reported by: | wonder | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.1 |
Component: | OGR_SF | Version: | |
Severity: | major | Keywords: | mysql |
Cc: |
Description
MySQL driver crashes in this scenario:
- call OGROpen("MYSQL:martin", false, 0) in main thread, later close the data source
- start a new thread
- call OGROpen("MYSQL:martin", false, 0) in the new thread
- CRASH
This happens in QGIS with the new multi-threaded rendering: http://hub.qgis.org/issues/10622
Tested with trunk, 1.11 and 1.10.1 Using MySQL 5.5.37
The crash happens inside load_defaults(...) called from OGRMySQLDataSource::Open(). Looking at that method, it seems like a relic from the past and I could not find any documentation for it. I believe that call (together with my_init()) should be replaced by mysql_library_init(...) call [1] that also allows passing of command line arguments and reading of configuration from mysql config files - that call should be done either in MySQL driver registration or in the Open() method, guarded with a mutex.
I have attached a draft patch that fixes the problem in QGIS. I have also removed the parts that explicitly read the "client" group info from my.cnf - according to the docs this should be done automatically by clients in mysql_library_init(0, NULL, NULL) call.
[1] http://dev.mysql.com/doc/refman/5.7/en/mysql-library-init.html
Attachments (1)
Change History (2)
by , 9 years ago
Attachment: | fix_mysql_threading_crash.diff added |
---|
comment:1 by , 9 years ago
Keywords: | mysql added |
---|---|
Milestone: | → 1.11.1 |
Resolution: | → fixed |
Status: | new → closed |
Version: | svn-trunk |
trunk r27505, branches/1.11 r27506 "MySQL: thread-safe initialization of mysql client library (#5528, derived from patch by wonder)"