Bug #43397 | mysql headers redefine pthread_mutex_init unnecessarily | ||
---|---|---|---|
Submitted: | 5 Mar 2009 2:45 | Modified: | 12 Mar 2010 17:45 |
Reporter: | Jess Balint | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: C API (client library) | Severity: | S3 (Non-critical) |
Version: | 5.1.32 | OS: | Linux |
Assigned to: | Staale Smedseng | CPU Architecture: | Any |
[5 Mar 2009 2:45]
Jess Balint
[5 Mar 2009 9:43]
Sveta Smirnova
Thank you for the report. Verified as described. Bug is not repeatable with current development sources.
[5 Mar 2009 9:46]
Sveta Smirnova
Bug existed in earlier 5.1 packages (tested since 5.1.11)
[6 Mar 2009 17:23]
Jess Balint
reported against 5.1.32, *current* release
[9 Apr 2009 19:23]
Jim Winstead
The problem here is that pthread_mutex_init() gets redefined when configured with --with-fast-mutexes based on flags which are written to my_config.h, but then is actually only redefined (and replaced with my_pthread_fastmutex_init) for libmysqlclient_r. So something that links against libmysqlclient (no _r) but uses pthread_mutex_init() will be looking for a routine that isn't there. Connector/ODBC links against both libmysqclient_r and libmysqclient (at least in 3.51), which is why it runs into this problem.
[8 Jul 2009 14:04]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/78215 3015 Staale Smedseng 2009-07-08 Bug #43397 mysql headers redefine pthread_mutex_init unnecessarily The problem is that libmysqlclient.so is built with THREAD undefined, while a client compiling against the same header files will see THREAD as defined and definitions in my_pthread.h will be included, possibly resulting in undefined symbols that cannot be resolved with libmysqlclient.so. The suggested solution is to require that clients wanting to link with libmysqlclient.so should be build with NO_THREADS defined. This requires a documentation change, and more details for this will be supplied if this patch is approved. The NO_THREADS define was renamed from UNDEF_THREADS_HACK, to get a more suitable (less suspicious) name for the define. This patch is also in anticipation of WL#4958, which will remove this problem altogether by dropping the building of the libmysqlclient.
[8 Jul 2009 14:50]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/78226 3015 Staale Smedseng 2009-07-08 Bug #43397 mysql headers redefine pthread_mutex_init unnecessarily The problem is that libmysqlclient.so is built with THREAD undefined, while a client compiling against the same header files will see THREAD as defined and definitions in my_pthread.h will be included, possibly resulting in undefined symbols that cannot be resolved with libmysqlclient.so. The suggested solution is to require that clients wanting to link with libmysqlclient.so should be built with MYSQL_CLIENT_NO_THREADS defined. This requires a documentation change, and more details for this will be supplied if this patch is approved. The MYSQL_CLIENT_NO_THREADS define was renamed from UNDEF_THREADS_HACK, to get a more suitable (less suspicious) name for the define. (The UNDEF_THREADS_HACK is retained for backwards compatibility, though.) This patch is also in anticipation of WL#4958, which will remove this problem altogether by dropping the building of libmysqlclient.
[10 Jul 2009 17:54]
Jim Winstead
I don't think this patch fixes this problem in any significant way. There is no reason that our public header files should ever be redefining a standard function like pthread_mutex_init().
[4 Aug 2009 19:51]
Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090804194615-h40sa098mx4z49qg) (version source revid:staale.smedseng@sun.com-20090710153603-pz0i5i78mu5pcng3) (merge vers: 5.4.4-alpha) (pib:11)
[26 Aug 2009 13:45]
Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46]
Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48]
Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32]
Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[28 Aug 2009 10:55]
Staale Smedseng
It is suggested that one or both of the following documentation sections are updated for this patch (referring to the 5.1 documentation section numbers here): 21.10.10.4 Problems Linking with the C API 21.10.16 Building Client Programs Possible wording: Linking with the single threaded library (libmysqlclient) may lead to linker errors related to pthread symbols. When using the single threaded library, please compile your client with MYSQL_CLIENT_NO_THREADS defined. This can be done on the command line by using the -D option to the compiler, or in your source code before including the MySQL header files. This define should not be used when building for use with the thread-safe client library (libmysqlclient_r).
[29 Aug 2009 23:40]
Paul DuBois
I added the suggested wording to 21.10.10.4, and repositioned it within the chapter as a subsection of 21.10.16.
[20 Dec 2009 18:02]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/95152 3288 Staale Smedseng 2009-12-20 Bug#43397 mysql headers redefine pthread_mutex_init unnecessarily Changing an instance of the define that was missed in the original commit due to the fact that it was misspelled.
[15 Jan 2010 9:00]
Bugs System
Pushed into 5.1.43 (revid:joro@sun.com-20100115085139-qkh0i0fpohd9u9p5) (version source revid:staale.smedseng@sun.com-20091220180215-zu7xs23cxge9mf2z) (merge vers: 5.1.42) (pib:16)
[5 Feb 2010 11:49]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100204063540-9czpdmpixi3iw2yb) (version source revid:alik@sun.com-20091224075613-es9uswo4lidkm3tj) (pib:16)
[5 Feb 2010 11:55]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100205113942-oqovjy0eoqbarn7i) (version source revid:alik@sun.com-20100204064210-ljwanqvrjs83s1gq) (merge vers: 6.0.14-alpha) (pib:16)
[5 Feb 2010 12:00]
Bugs System
Pushed into 5.5.2-m2 (revid:alik@sun.com-20100203172258-1n5dsotny40yufxw) (version source revid:alexey.kopytov@sun.com-20091223134205-pk9yvgfvpn3hy7lh) (merge vers: 5.5.1-m2) (pib:16)
[12 Mar 2010 14:19]
Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:33]
Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:50]
Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)