Comment 4 for bug 1011047

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Verified the bug. The crash happens because global_table_stats is not initialized when my_hash_insert is invoked on it resulting in segfault.

Complete backtrace:

#0 0x00007ffff6185fa5 in raise () from /lib/libc.so.6
#1 0x00007ffff6187428 in abort () from /lib/libc.so.6
#2 0x00007ffff617f002 in __assert_fail_base () from /lib/libc.so.6
#3 0x00007ffff617f0b2 in __assert_fail () from /lib/libc.so.6
#4 0x00000000008c5f36 in my_realloc (oldpoint=0x0, size=0, my_flags=my_flags@entry=80) at /media/Vone/percona-server/raghu/Percona-Server/mysys/my_malloc.c:81
#5 0x000000000089ee95 in alloc_dynamic (array=array@entry=0x1b8c168 <global_table_stats+40>) at /media/Vone/percona-server/raghu/Percona-Server/mysys/array.c:150
#6 0x00000000008a485c in my_hash_insert (info=0x1b8c140 <global_table_stats>, record=0x1e22a90 "mysql.plugin") at /media/Vone/percona-server/raghu/Percona-Server/mysys/hash.c:382
#7 0x00000000007451cc in handler::update_global_table_stats (this=0x1e20490) at /media/Vone/percona-server/raghu/Percona-Server/sql/handler.cc:3871
#8 0x0000000000571623 in close_thread_table (thd=thd@entry=0x7fffffffb100, table_ptr=table_ptr@entry=0x7fffffffb1a0) at /media/Vone/percona-server/raghu/Percona-Server/sql/sql_base.cc:1598
#9 0x0000000000571de6 in close_open_tables (thd=0x7fffffffb100) at /media/Vone/percona-server/raghu/Percona-Server/sql/sql_base.cc:1362
#10 close_thread_tables (thd=0x7fffffffb100) at /media/Vone/percona-server/raghu/Percona-Server/sql/sql_base.cc:1569
#11 0x00000000005815dd in close_mysql_tables (thd=0x7fffffffb100) at /media/Vone/percona-server/raghu/Percona-Server/sql/sql_base.cc:9326
#12 0x00000000005dd16d in plugin_load (tmp_root=tmp_root@entry=0x7fffffffe310, argc=argc@entry=0x1a9915c <remaining_argc>, argv=argv@entry=0x1ddf700) at /media/Vone/percona-server/raghu/Percona-Server/sql/sql_plugin.cc:1526
#13 0x00000000005deee6 in plugin_init (argc=0x1a9915c <remaining_argc>, argv=0x1ddf700, flags=0) at /media/Vone/percona-server/raghu/Percona-Server/sql/sql_plugin.cc:1367
#14 0x0000000000529487 in init_server_components () at /media/Vone/percona-server/raghu/Percona-Server/sql/mysqld.cc:3952
#15 0x000000000052ab7a in mysqld_main (argc=22, argv=0x1ddf700) at /media/Vone/percona-server/raghu/Percona-Server/sql/mysqld.cc:4672
#16 0x000000000051d9dd in main (argc=<optimized out>, argv=<optimized out>) at /media/Vone/percona-server/raghu/Percona-Server/sql/main.cc:25

====================

The fix provided by yinfeng is good, however, need to move the other init upwards too:

=== modified file 'Percona-Server/sql/mysqld.cc'
--- Percona-Server/sql/mysqld.cc 2012-08-07 06:10:00 +0000
+++ Percona-Server/sql/mysqld.cc 2012-08-23 17:54:46 +0000
@@ -3947,6 +3947,9 @@
     sql_print_warning("ignore-builtin-innodb is deprecated "
                       "and will be removed in future releases.");

+ init_global_table_stats();
+ init_global_index_stats();
+
   if (plugin_init(&remaining_argc, remaining_argv,
                   (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
                   (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
@@ -4007,8 +4010,6 @@
   /* We have to initialize the storage engines before CSV logging */
   TC_init();

- init_global_table_stats();
- init_global_index_stats();

   if (ha_init())
   {

init_global_index_stats also needs to be moved up because if the loaded non-builtin plugin has any tables with indexes then global_index_stats will also be non-initialized and will segfault again.

Also, tested.