Bug #40733 When started as root 6.0.8 server crashes on startup
Submitted: 14 Nov 2008 10:40 Modified: 10 Jul 2009 16:50
Reporter: Alexey Stroganov Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:6.0.8-release, 5.4 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: regression

[14 Nov 2008 10:40] Alexey Stroganov
Description:
I've tried to start mysql server as root as following and got crash right away(see below). However if I will add ---user=root it will work ok.

cd mysql-6.0.8-alpha-pb97-linux-x86_64
./bin/mysqld

081114 11:38:42 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

081114 11:38:42 [ERROR] Aborting

081114 11:38:42 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=0
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 330231 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = (nil) thread_stack 0x40000
./bin/mysqld-debug(my_print_stacktrace+0x29) [0xa6a8c9]
./bin/mysqld-debug(handle_segfault+0x25c) [0x6351e1]
/lib64/libpthread.so.0 [0x2ae0225b4140]
./bin/mysqld-debug(delegates_destroy()+0x8) [0x7d7cc3]
./bin/mysqld-debug [0x6342f4]
./bin/mysqld-debug(unireg_abort+0x122) [0x636237]
./bin/mysqld-debug(main+0x266) [0x638747]
/lib64/libc.so.6(__libc_start_main+0xf4) [0x2ae022d83154]
./bin/mysqld-debug(__strtoll_internal+0x42) [0x57ed7a]

bt:
(gdb) bt
#0  0x00002b7d14ad04c5 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000a6a89e in my_write_core (sig=11) at stacktrace.c:307
#2  0x0000000000635373 in handle_segfault (sig=11) at mysqld.cc:2673
#3  <signal handler called>
#4  delegates_destroy () at rpl_handler.h:129
#5  0x00000000006342f4 in clean_up (print_message=true) at mysqld.cc:1359
#6  0x0000000000636237 in unireg_abort (exit_code=1) at mysqld.cc:1289
#7  0x0000000000638747 in main (argc=<value optimized out>, argv=<value optimized out>) at mysqld.cc:1583

How to repeat:
cd mysql-6.0.8-alpha-pb97-linux-x86_64
./bin/mysqld
[14 Nov 2008 10:43] Alexey Stroganov
Cut&paste typo in report above:

Read  mysql-6.0.8-alpha-linux-x86_64-glibc23 instead of mysql-6.0.8-alpha-pb97-linux-x86_64.
[16 Jun 2009 5:20] Vladimir Shebordaev
I can't reproduce this bug in current 6.0.12-alpha built with gcc 4.3.2 (compile-pentium-max on P4).

But the debug mysqld gets aborted in safe_mutex_destroy() called for uninitialized mutex in end_slave_start() in the same unireg_abort() path:

# ./mysqld --version
./mysqld  Ver 6.0.12-alpha-debug for pc-linux-gnu on i686 (Source distribution)

# ./mysqld                                           
090616  6:03:34 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

090616  6:03:34 [ERROR] Aborting

safe_mutex: Trying to destroy unitialized mutex at sql_repl.cc, line 1027
090616  6:03:34 - mysqld got signal 6 ;

[ skipped ]

thd: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = (nil) thread_stack 0x30c00
./mysqld(my_print_stacktrace+0x32) [0x894682c]
./mysqld(handle_segfault+0x2db) [0x8322241]
[0x71a400]
/lib/libc.so.6(abort+0x188) [0xa12e28]
./mysqld(safe_mutex_destroy+0xbe) [0x8920502]
./mysqld(end_slave_start()+0x22) [0x84d7384]
./mysqld [0x8323d4b]
./mysqld(unireg_abort+0x7d) [0x8323feb]
./mysqld [0x83266aa]
./mysqld(main+0x187) [0x8326902]
/lib/libc.so.6(__libc_start_main+0xe5) [0x9fc6e5]
./mysqld [0x823bdb1]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

Basically, these bugs are due to the server is aborted with unireg_abort() in check_user() before init_server_components() is called. I guess the bug described in the original report is caused by improper  reference to certain uninitialized object perhaps due to minor gcc bug.

For the sake of consistency it would be nice to introduce a flag to indicate whether it's safe to unwind initialization with clean_up() in unireg_abort(). One can safely call clean_up() in unireg_abort() just after start_handle_manager() is invoked at mysqld.cc:4703.
[10 Jul 2009 16:50] Alfranio Tavares Correia Junior
Duplicate of BUG#43533.