Bug #59564 mysql 5.5.8 connecting via mysql client segfault
Submitted: 17 Jan 2011 18:34 Modified: 20 Jan 2011 9:38
Reporter: Alex Galitsky Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:5.5.8 OS:Any (CentOS 5.5)
Assigned to: CPU Architecture:Any

[17 Jan 2011 18:34] Alex Galitsky
Description:
Downloaded MySql 5.5.8 source code

Compiled using following options:

/opt/cmake/bin/cmake . -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/mysql/mysql-5.5.8/data/ \
-DCMAKE_INSTALL_PREFIX=/mysql/mysql-5.5.8 -DCURSES_LIBRARY=/opt/ncurses/lib/libncurses.a \
-DCURSES_INCLUDE_PATH=/opt/ncurses/include/ -DHAVE_LIBAIO_H=/opt/libaio/include/ \
-DINSTALL_LAYOUT=STANDALONE -DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF -DWITH_DEBUG=OFF

make
make test
make install

./scripts/mysql_install_db --user=mysql --datadir=/mysql/mysql-5.5.8/data

Installing MySQL system tables...
OK
Filling help tables...
OK

./bin/mysql --socket=/mysql/mysql.sock  -uroot -p
Enter password:
....................................................
....................................................
....................................................
Segmentation fault

tail /var/log/messages:
....................
Jan 17 13:03:48 imsdev2 kernel: mysql[10630]: segfault at ffffffff89c7c410 rip 0000000000449cd1 rsp 00007fff89c7bbd0 error 4
....................

objdump -DCl "/path/to/YOUR_APPLICATION" > APPLICATION_DEBUG

grep -n -A 6 -B 6 "449cd1" APPLICATION_DEBUG

111769-/root/downloads/mysql-5.5.8/cmd-line-utils/libedit/term.c:396
111770-  449cc8:        48 85 d2                test   %rdx,%rdx
111771-/root/downloads/mysql-5.5.8/cmd-line-utils/libedit/term.c:394
111772-  449ccb:        48 8d 2c 1e             lea    (%rsi,%rbx,1),%rbp
111773-/root/downloads/mysql-5.5.8/cmd-line-utils/libedit/term.c:396
111774-  449ccf:        74 05                   je     449cd6 <term_alloc+0x36>
111775:  449cd1:        80 3a 00                cmpb   $0x0,(%rdx)
111776-  449cd4:        75 1a                   jne    449cf0 <term_alloc+0x50>
111777-/root/downloads/mysql-5.5.8/cmd-line-utils/libedit/term.c:397
111778-  449cd6:        48 c7 45 00 00 00 00    movq   $0x0,0x0(%rbp)
111779-  449cdd:        00
111780-/root/downloads/mysql-5.5.8/cmd-line-utils/libedit/term.c:446
111781-  449cde:        48 81 c4 08 08 00 00    add    $0x808,%rsp

Please advise

How to repeat:
Every time when I am running command
[17 Jan 2011 18:38] Alex Galitsky
Some additional info:

# uname -a
Linux localhost 2.6.18-194.26.1.el5 #1 SMP Tue Nov 9 12:54:20 EST 2010 x86_64 x86_64 x86_64 GNU/Linux

# gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
[17 Jan 2011 21:48] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior. Please try to compile without curses-related options and inform us if it works.
[18 Jan 2011 17:40] Alex Galitsky
Hi Sveta
Thank you for prompt response

I build using that command:

/opt/cmake/bin/cmake . -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/mysql/mysql-5.5.8/data/ \
-DCMAKE_INSTALL_PREFIX=/mysql/mysql-5.5.8  -DHAVE_LIBAIO_H=/opt/libaio/include/ \
-DINSTALL_LAYOUT=STANDALONE -DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF -DWITH_DEBUG=ON

Same result - segmentation fault on mysql

May I ask - the whole reason for my action is desire to install MySql into different directory and keep older version of MySql if a fallback will be needed
Is there way to install MySql into directory different from the default one?
Say, in /mysql dir, not in /usr/bin/mysql

Thank you very much
[18 Jan 2011 19:11] Alex Galitsky
Did strace on mysql command

Attachment: strace mysql.txt (text/plain), 15.78 KiB.

[18 Jan 2011 23:12] Vladislav Vaintroub
out of curiosity - why the cmake command line is so obfuscated?

Normally, you should be able to get a good server with

cmake .
make package
[18 Jan 2011 23:18] Vladislav Vaintroub
wild guess is that it would be non-standard curses library (set with CURSES_LIBRARY via cmake option), I think typical build would link with system shared library.
[18 Jan 2011 23:37] Vladislav Vaintroub
I believe strace confirms theory about curses.
in particular libncurses.so.5 is not loaded when mysql starts, so it must be statically linked in.

build from scratch (or just removing CMakeCache.txt and rerunning cmake and make) would probably fix it.
[19 Jan 2011 16:45] Alex Galitsky
Hi Vladislav

Thank you for comments
I did build MySql from scratch and now it is working
The command was:

/opt/cmake/bin/cmake . -DMYSQL_DATADIR=/mysql/mysql-5.5.8/data/ \
	-DCMAKE_INSTALL_PREFIX=/mysql/mysql-5.5.8

As you had correctly guessed, the problem was with ncurses
I had to install ncurses-devel with following command:
                        yum install ncurses-devel

The build generated several warning
I am able to connect to MySql server via mysql command

However, I had found a possible problem:
I did run mysql-test-run.pl and it had failed on rpl.rpl_semi_sync 'mix'   

I had attached file with output of build and test commands

Could you take a look, please

Thank you very much for your help
[19 Jan 2011 16:46] Alex Galitsky
Log file of MySql build and mysql-test-run.pl. Please see end of file for failed test

Attachment: mysql build.txt (text/plain), 142.72 KiB.

[19 Jan 2011 16:59] Vladislav Vaintroub
Cool, I guess the original build problem is solved. 

I think you'll need to open another bug to track rpl semisync error specifically, so replication specialists can take a look.

In the meantime, might want to run mysql-test-run.pl with --force so it does not die on the first error (it will report all errors at the end still)
[19 Jan 2011 18:00] Alex Galitsky
Vladislav,

may I ask one more thing, please: can you take a look at hte MySql build file and confirm the warnings I got are not important

Thanks a lot
[19 Jan 2011 18:27] Vladislav Vaintroub
I see only "type-punning strict-aliasing" ones. It would be generalization to say they are not important, to prove otherwise, I would have to look at every single one.

The type-punning warnings are known ones and are being handled in http://bugs.mysql.com/bug.php?id=42733

But, those are also GCC version specific (and actually GCC-only thing), and known for false positives, and it seems really hard to achieve warning-free state in all circumstances.
[19 Jan 2011 18:33] Alex Galitsky
Vladislav, thank you very much for all your help

Please close that bug

Thank you again,

Alex Galitsky
[20 Jan 2011 9:38] Sveta Smirnova
Thank you for the feedback.

Closed as "Can't repeat"