Bug #84221 SIGSEGV in mysql_upgrade

Submitted: 16 Dec 2016 0:45 Modified: 16 Dec 2016 13:00
Reporter: Anatoli · Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S1 (Critical)
Version:5.7.17 OS:Ubuntu (Ubuntu 14.04.5 LTS)
Assigned to: CPU Architecture:Any
Tags: mysql_upgrade

[16 Dec 2016 0:45] Anatoli ·
Description:
Hi,

When compiling all mysql binaries from sources (5.7.17), I'm getting a SEGFAULT in mysql_upgrade just before it tries to connect to the server if I pass a -DDEFAULT_COLLATION=utf8_unicode_ci option to cmake. If I don't specify this argument, or specify another collation (e.g. utf8_general_ci) everything works fine.

Here is how I compile it:

$ mkdir bld && cd bld
$ cmake .. -LH \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
 \
-DENABLE_DOWNLOADS=OFF \
-DWITH_BOOST=../boost/boost_1_59_0/ \
 \
-DWITH_DEBUG=1

$ make

$ ./client/mysql_upgrade
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Segmentation fault

Here is a backtrace:

$ gdb ./client/mysql_upgrade
(gdb) r
Starting program: /home/user1/build/mysql-5.7.17/bld/client/mysql_upgrade
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000000004eae85 in Mysql::Tools::Base::Mysql_query_runner::get_message_type_from_severity (this=0x7fffffffe560, severity="Warning")
    at /home/user1/build/mysql-5.7.17/client/base/mysql_query_runner.cc:248
#2  0x00000000004eaa38 in Mysql::Tools::Base::Mysql_query_runner::run_query_unguarded (this=0x7fffffffe560, query="set sql_mode='';\n")
    at /home/user1/build/mysql-5.7.17/client/base/mysql_query_runner.cc:201
#3  0x00000000004ea637 in Mysql::Tools::Base::Mysql_query_runner::run_query (this=0x7fffffffe560, query="set sql_mode='';\n") at /home/user1/build/mysql-5.7.17/client/base/mysql_query_runner.cc:118
#4  0x00000000004086a3 in Mysql::Tools::Upgrade::Program::run_sql_fix_privilege_tables (this=0xaf3e80 <program>) at /home/user1/build/mysql-5.7.17/client/upgrade/program.cc:610
#5  0x0000000000406462 in Mysql::Tools::Upgrade::Program::execute (this=0xaf3e80 <program>, positional_options=std::vector of length 0, capacity 0)
    at /home/user1/build/mysql-5.7.17/client/upgrade/program.cc:209
#6  0x00000000004e7520 in Mysql::Tools::Base::Abstract_program::run (this=0xaf3e80 <program>, argc=0, argv=0xb034d0) at /home/user1/build/mysql-5.7.17/client/base/abstract_program.cc:98
#7  0x0000000000405c2c in main (argc=1, argv=0x7fffffffeb68) at /home/user1/build/mysql-5.7.17/client/upgrade/program.cc:987

# Debugging a working build (with -DDEFAULT_COLLATION=utf8_general_ci):

(gdb) l 248
243	    uint dummy_errors;
244	    severity_string.copy(Message_data::message_type_strings[i],
245	      strlen(Message_data::message_type_strings[i]),
246	      &my_charset_latin1, m_connection->charset, &dummy_errors);
247
248	    if (my_strcasecmp(m_connection->charset, severity.c_str(),
249	      severity_string.c_ptr_safe()) == 0)
250	    {
251	      return (Message_type)i;
252	    }
(gdb) p m_connection->charset
$12 = (charset_info_st *) 0xa91020 <my_charset_utf8_general_ci>
(gdb) p severity
$13 = "Warning"
(gdb) p severity_string
No symbol "severity_string" in current context.

# Debugging a SEGFAULTing build (with -DDEFAULT_COLLATION=utf8_unicode_ci):

(gdb) l 248
243	    uint dummy_errors;
244	    severity_string.copy(Message_data::message_type_strings[i],
245	      strlen(Message_data::message_type_strings[i]),
246	      &my_charset_latin1, m_connection->charset, &dummy_errors);
247
248	    if (my_strcasecmp(m_connection->charset, severity.c_str(),
249	      severity_string.c_ptr_safe()) == 0)
250	    {
251	      return (Message_type)i;
252	    }
(gdb) p m_connection->charset
$1 = (charset_info_st *) 0xae3200 <my_charset_utf8_unicode_ci>
(gdb) p severity
$2 = "Warning"
(gdb) p severity_string
$3 = {m_ptr = 0xb116d0 "INFORMATION", m_length = 11, m_charset = 0xae3200 <my_charset_utf8_unicode_ci>, m_alloced_length = 40, m_is_alloced = true}

All other binaries (both client and server) work fine (no SEGFAULTs detected yet).

Please let me know if additional info is needed.

Regards,
Aantoli

How to repeat:
From the sources dir:

$ mkdir bld && cd bld
$ cmake .. -LH \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
 \
-DENABLE_DOWNLOADS=OFF \
-DWITH_BOOST=../boost/boost_1_59_0/ \
 \
-DWITH_DEBUG=1

$ make

$ ./client/mysql_upgrade
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Segmentation fault
[16 Dec 2016 13:00] MySQL Verification Team
I couldn't repeat on Fedora 23:

[miguel@fedora23 mysql-5.7.17]$ cmake . -LH -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci  -DENABLE_DOWNLOADS=OFF -DWITH_BOOST=../boost/boost_1_59_0/  -DWITH_DEBUG=1
-- Running cmake version 3.4.3
-- Found Git: /usr/bin/git (found version "2.5.0") 
-- Configuring with MAX_INDEXES = 64U
-- Looking for SHM_HUGETLB
-- Looking for SHM_HUGETLB - found
-- Looking for sys/types.h
<cut>
-- Configuring done
-- Generating done
-- Build files have been written to: /home/miguel/mysql-5.7.17
-- Cache values
[miguel@fedora23 mysql-5.7.17]$ make
Scanning dependencies of target INFO_BIN
[  0%] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[  0%] Built target INFO_SRC
Scanning dependencies of target abi_check
[  0%] Built target abi_check
Scanning dependencies of target zlib
[  0%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o
[  0%] Building C object zlib/CMakeFiles/zlib.dir/compress.c.o
<CUT>
[100%] Built target mysqltest_embedded
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
[100%] Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[miguel@fedora23 mysql-5.7.17]$ ./client/mysql_upgrade
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
The sys schema is already up to date (version 1.5.1).
Checking databases.
sys.sys_config                                     OK
Upgrade process completed successfully.
Checking if update is needed.
[miguel@fedora23 5.7]$ bin/mysql_upgrade 
mysql_upgrade: Got error: 1045: Access denied for user 'miguel'@'localhost' (using password: NO) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
[miguel@fedora23 5.7]$ bin/mysql_upgrade  -uroot
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.17, use --force if you still need to run mysql_upgrade
[miguel@fedora23 5.7]$ bin/mysql_upgrade  -uroot --force
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
The sys schema is already up to date (version 1.5.1).
Checking databases.
sys.sys_config                                     OK
Upgrade process completed successfully.
[21 Jul 2017 12:15] Mr Jay
I can confirm that mysql_upgrade segfaults in multiple 5.7-versions.
Last version tested is 5.7.19 (ndbcluster 7.5.7)

Standard 64bit linux.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.