Bug #82853 mysqldump crashes when invoked with '--compatible=m'
Submitted: 4 Sep 2016 8:06 Modified: 4 Sep 2016 9:38
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:5.7.14, 5.6.32, 5.5.51 OS:Any
Assigned to: CPU Architecture:Any
Tags: crash

[4 Sep 2016 8:06] Daniël van Eeden
Description:
"mysqldump --compatible=m" results in a segmentation fault

This happens if the compatible option matches more than one.

"my" matches mysql323 and mysql40 and crashes
"ma" matchies only maxdb and doesn't crash

How to repeat:
Run mysqldump --compatible=m

It does crash on a release version:
mysqldump  Ver 10.13 Distrib 5.7.14, for linux-glibc2.5 (x86_64)

It does not crash on a custom compiled debug version:
mysqldump  Ver 10.13 Distrib 5.7.14, for Linux (x86_64)

The debug build was compliled with -DCMAKE_BUILD_TYPE=Debug and GCC 6.1.1 on Fedora 24

[dvaneeden@dve-mac ~]$ gdb --args /opt/mysql/5.7.14/bin/mysqldump --compatible=m
GNU gdb (GDB) Fedora 7.11.1-75.fc24
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /opt/mysql/5.7.14/bin/mysqldump...done.
(gdb) r
Starting program: /opt/mysql/5.7.14/bin/mysqldump --compatible=m
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
__stpcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
296		movdqu	(%rsi), %xmm1
(gdb) bt
#0  __stpcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
#1  0x000000000040d309 in my_stpcpy (src=<optimized out>, dst=<optimized out>)
    at /export/home/pb2/build/sb_0-19699473-1468327072.46/mysql-5.7.14/include/m_string.h:81
#2  get_one_option (optid=<optimized out>, opt=<optimized out>, argument=<optimized out>)
    at /export/home/pb2/build/sb_0-19699473-1468327072.46/mysql-5.7.14/client/mysqldump.c:936
#3  0x0000000000457b2b in my_handle_options (argc=0x7fffffffda6c, argv=<optimized out>, 
    longopts=0x99cf20 <my_long_options>, get_one_option=0x40ca50 <get_one_option>, 
    command_list=<optimized out>, ignore_unknown_option=0 '\000')
    at /export/home/pb2/build/sb_0-19699473-1468327072.46/mysql-5.7.14/mysys_ssl/my_getopt.cc:571
#4  0x0000000000418135 in get_options (argv=0x7fffffffda60, argc=0x7fffffffda6c)
    at /export/home/pb2/build/sb_0-19699473-1468327072.46/mysql-5.7.14/client/mysqldump.c:1021
#5  main (argc=1, argv=0xa29d28)
    at /export/home/pb2/build/sb_0-19699473-1468327072.46/mysql-5.7.14/client/mysqldump.c:5989
(gdb) q
A debugging session is active.

	Inferior 1 [process 16943] will be killed.

Quit anyway? (y or n) y
[dvaneeden@dve-mac ~]$ /opt/mysql/5.7.14/bin/mysqldump --version
mysqldump  Ver 10.13 Distrib 5.7.14, for linux-glibc2.5 (x86_64)
[dvaneeden@dve-mac ~]$ file /opt/mysql/5.7.14/bin/mysqldump
/opt/mysql/5.7.14/bin/mysqldump: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.9, not stripped
[dvaneeden@dve-mac ~]$ sha1sum /opt/mysql/5.7.14/bin/mysqldump
ec39aee54a32bb0cd6e8418a04965cf56c38a89b  /opt/mysql/5.7.14/bin/mysqldump

I tried a mysqldump compiled with -DCMAKE_BUILD_TYPE=RelWithDebInfo and that didn't crash. 
So I guess this might have something to do with the platform and/or compliler on which the binary was build.
[4 Sep 2016 9:38] MySQL Verification Team
Hello Daniël,

Thank you for the report.
Verified as described.

Thanks,
Umesh