Bug #69653 | Use of uninitialized pthread_getspecific() key in debug builds | ||
---|---|---|---|
Submitted: | 3 Jul 2013 5:34 | Modified: | 1 Oct 2013 15:41 |
Reporter: | Alexey Kopytov | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Logging | Severity: | S3 (Non-critical) |
Version: | 5.6 | OS: | Any |
Assigned to: | Marc ALFF | CPU Architecture: | Any |
[3 Jul 2013 5:34]
Alexey Kopytov
[7 Jul 2013 11:44]
Marc ALFF
This bug has been fixed in 5.7 already, see in particular: http://bazaar.launchpad.net/~mysql/mysql-server/5.7/view/head:/mysys/my_thr_init.c#L471 extern void **my_thread_var_dbug() { struct st_my_thread_var *tmp; /* Instead of enforcing DBUG_ASSERT(THR_KEY_mysys_initialized) here, which causes any DBUG_ENTER and related traces to fail when used in init / cleanup code, we are more tolerant: using DBUG_ENTER / DBUG_PRINT / DBUG_RETURN when the dbug instrumentation is not in place will do nothing. */ if (! THR_KEY_mysys_initialized) return NULL; tmp= _my_thread_var(); return tmp && tmp->init ? &tmp->dbug : 0; } The revision that fixed that is: http://bazaar.launchpad.net/~mysql/mysql-server/5.7/revision/5107.1.280 Committer: Marc Alff Date: 2013-01-16 16:38:07 UTC mto: (4526.1.81 mysql-trunk-wl6469) (4423.1.10 wl6455-0218) (4764.1.131 mysql-trunk-wl6560) (5107.21.1 trunk6) mto: This revision was merged to the branch mainline in revision 5112. Revision ID: marc.alff@oracle.com-20130116163807-lbe97qhzvv62qkcb Bug#16175473 TUNING, USE STATIC CALLS FOR THE PERFORMANCE SCHEMA INSTRUMENTATION This change is a performance tuning improvement. Before this fix, a line of code instrumented as: PSI_MUTEX_CALL(start_mutex_wait)(...); would always be compiled using a indirect call, using a function pointer: PSI_server->start_mutex_wait(...); This is expected when building code for dynamic plugins, but inefficient when building code inside the server itself. With this fix, the same line of code is now compiled as either PSI_server->start_mutex_wait(...); or pfs_start_mutex_wait_v1(...); depending of whether a dynamic or static call is needed. The net result is that instrumentation calls for the server code itself can now be compiled staticly. The server code has been adjusted to use static calls for the instrumentation interface, which affected the server initialization code. As part of this change, helper functions are defined to wrap access to thread local storage, so that detecting invalid TLS usage is easier. --- The fix is not present in 5.6.
[1 Oct 2013 15:41]
Paul DuBois
Noted in 5.6.15, 5.7.3 changelogs. In debug builds, static initialization code could call DBUG functions before the DBUG subsystem was initialized.
[4 Dec 2013 11:23]
Laurynas Biveinis
5.6$ bzr log -r 5411 -n0 ------------------------------------------------------------ revno: 5411 [merge] committer: Marc Alff <marc.alff@oracle.com> branch nick: mysql-5.6-push timestamp: Wed 2013-08-28 11:02:34 +0200 message: Merge to mysql-5.6 (backport) ------------------------------------------------------------ revno: 5285.1.2 [merge] committer: Marc Alff <marc.alff@oracle.com> branch nick: mysql-5.6-bug17063675 timestamp: Mon 2013-08-26 11:55:13 +0200 message: Local merge ------------------------------------------------------------ revno: 5285.1.1 committer: Marc Alff <marc.alff@oracle.com> branch nick: mysql-5.6-bug17063675 timestamp: Sun 2013-07-07 16:16:00 +0200 message: Bug#17063675 USE OF UNINITIALIZED PTHREAD_GETSPECIFIC() KEY IN DEBUG BUILDS Before this fix, code that uses DBUG_ENTER() and related macros, when executed very early in the server initialization, typically when using C++ constructors in static code, could end up executing my_pthread_getspecific() with a non initialized pthread_key. The behavior in this case is undefined, and can potentially cause a crash. This fix is a backport from MySQL 5.7, which uses a THR_KEY_mysys_initialized variable to keep track of the initialization state. With this fix, calling DBUG_ENTER() and related macro is more robust, and does nothing when the debug component is not available.