Bug #35927 global g_eventLogger breaks dlopened libndbclient
Submitted: 9 Apr 2008 9:11 Modified: 2 Jul 2008 19:36
Reporter: Monty Taylor Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: NDB API Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Monty Taylor CPU Architecture:Any
Triage: D1 (Critical)

[9 Apr 2008 9:11] Monty Taylor
Description:
When trying to use libndbclient compiled --with-debug as part of a dlopen call in NDB/J, we get the following segfault:

#0  0x00007ff4fc1cf095 in raise () from /lib/libc.so.6
(gdb) bt
#0  0x00007ff4fc1cf095 in raise () from /lib/libc.so.6
#1  0x00007ff4fc1d0af0 in abort () from /lib/libc.so.6
#2  0x00007ff4fbd23fd7 in os::abort ()
   from /usr/lib/jvm/java-6-sun-1.6.0.05/jre/lib/amd64/server/libjvm.so
#3  0x00007ff4fbe8279d in VMError::report_and_die ()
   from /usr/lib/jvm/java-6-sun-1.6.0.05/jre/lib/amd64/server/libjvm.so
#4  0x00007ff4fbd292ec in JVM_handle_linux_signal ()
   from /usr/lib/jvm/java-6-sun-1.6.0.05/jre/lib/amd64/server/libjvm.so
#5  0x00007ff4fbd2613e in signalHandler ()
   from /usr/lib/jvm/java-6-sun-1.6.0.05/jre/lib/amd64/server/libjvm.so
#6  <signal handler called>
#7  0x00007ff4c2aa5648 in DoTrace ()
   from /home/mtaylor/src/dbug_crash_testcase/libtest.so
#8  0x00007ff4c2aa61b4 in _db_enter_ ()
   from /home/mtaylor/src/dbug_crash_testcase/libtest.so
#9  0x00007ff4c27de801 in NdbMutex_Create () from /usr/lib/libndbclient.so.4
#10 0x00007ff4c27dc0d9 in Logger::Logger () from /usr/lib/libndbclient.so.4
#11 0x00007ff4c27c546b in EventLogger::EventLogger ()
   from /usr/lib/libndbclient.so.4
#12 0x00007ff4c27a4aa2 in ?? () from /usr/lib/libndbclient.so.4
#13 0x00007ff4c27ee772 in ?? () from /usr/lib/libndbclient.so.4
#14 0x00000000401d8e30 in ?? ()
#15 0x00000000401d7fc0 in ?? ()

The problem here is in ndb_cluster_connection.cpp there is a global EventLogger g_eventLogger; 

How to repeat:
Download ndb/j. Compile mysql with-debug. Run an ndb/j test program. Watch the segfault. 

Suggested fix:
Make 

EventLogger g_eventLogger;

into 

EventLogger * g_eventLogger;

and initialize either in ndb_init() or on the first invocation of Ndb_cluster_connection.
[9 Apr 2008 9:12] Monty Taylor
Jonas and I verified this in person.
[9 Apr 2008 12:17] 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/45121

ChangeSet@1.2578, 2008-04-09 14:16:17+02:00, mtaylor@solace.(none) +27 -0
  BUG#35927 global g_eventLogger breaks dlopened libndbclient
  
  Changed g_eventLogger to be a reference initialized on construction of the
  first Ndb_cluster_connection.
[9 Apr 2008 13:12] 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/45129

ChangeSet@1.2579, 2008-04-09 15:10:26+02:00, mtaylor@solace.(none) +5 -0
  BUG#35927 global g_eventLogger breaks dlopened libndbclient
  
  Moved initialization of the g_eventLogger to ndb_init.
[9 Apr 2008 13:34] 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/45133

ChangeSet@1.2580, 2008-04-09 15:34:01+02:00, mtaylor@solace.(none) +1 -0
  BUG#35927 global g_eventLogger breaks dlopened libndbclient
  
  Made ndb_init_called static to not pollute the global namespace.
[10 Apr 2008 12:05] 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/45185

ChangeSet@1.2578, 2008-04-09 23:07:46+02:00, mtaylor@solace.(none) +30 -0
  Bug #35927  	global g_eventLogger breaks dlopened libndbclient
  
  Initialize g_eventLogger in ndb_init instead of statically. 
  Initialize f_invalid_table and f_altered_table on first use.
[11 Apr 2008 15:06] Magnus BlÄudd
Move the "ndb_init_called= 1" to the line just after it is check. Gives better protection against double init.
[14 Apr 2008 23:07] 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/45389

ChangeSet@1.2578, 2008-04-11 21:35:34+02:00, mtaylor@solace.(none) +30 -0
  Bug #35927  	global g_eventLogger breaks dlopened libndbclient
  
  Initialize g_eventLogger in ndb_init instead of statically. 
  Initialize f_invalid_table and f_altered_table on first use.
[22 Apr 2008 18:42] 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/45834

ChangeSet@1.2578, 2008-04-22 11:42:03-07:00, mtaylor@solace.(none) +30 -0
  Bug #35927  	global g_eventLogger breaks dlopened libndbclient
  
  Initialize g_eventLogger in ndb_init instead of statically. 
  Initialize f_invalid_table and f_altered_table on first use.
[22 Apr 2008 18:58] 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/45835

ChangeSet@1.2578, 2008-04-22 11:58:19-07:00, mtaylor@solace.(none) +30 -0
  Bug #35927  	global g_eventLogger breaks dlopened libndbclient
  
  Initialize g_eventLogger in ndb_init instead of statically. 
  Initialize f_invalid_table and f_altered_table on first use.
[22 Apr 2008 19:36] 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/45838

ChangeSet@1.2578, 2008-04-22 12:36:05-07:00, mtaylor@solace.(none) +30 -0
  Bug #35927  	global g_eventLogger breaks dlopened libndbclient
  
  Initialize g_eventLogger in ndb_init instead of statically. 
  Initialize f_invalid_table and f_altered_table on first use.
[2 Jul 2008 19:35] Jon Stephens
Documented in the NDB 6.2.15 and 6.3.14 changelogs as follows:

        Accesing the debug version of libndbclient via
        dlopen() resulted in a segmentation fault.
[2 Jul 2008 19:36] Jon Stephens
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/
[12 Dec 2008 23:25] Bugs System
Pushed into 6.0.6-alpha  (revid:sp1r-mtaylor@solace.(none)-20080422193605-07612) (version source revid:jonas@mysql.com-20080808094047-4e1yiarqa2t3opg3) (pib:5)