Opened 10 years ago

Closed 10 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:

  1. call OGROpen("MYSQL:martin", false, 0) in main thread, later close the data source
  2. start a new thread
  3. call OGROpen("MYSQL:martin", false, 0) in the new thread
  4. 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)

fix_mysql_threading_crash.diff (1.9 KB ) - added by wonder 10 years ago.

Download all attachments as: .zip

Change History (2)

by wonder, 10 years ago

comment:1 by Even Rouault, 10 years ago

Keywords: mysql added
Milestone: 1.11.1
Resolution: fixed
Status: newclosed
Version: svn-trunk

trunk r27505, branches/1.11 r27506 "MySQL: thread-safe initialization of mysql client library (#5528, derived from patch by wonder)"

Note: See TracTickets for help on using tickets.