Bug #2426 Segfault on exit from mysql client, versions 4.1.0 and 4.1.1
Submitted: 16 Jan 2004 7:30 Modified: 3 May 2004 10:44
Reporter: Scott Courtney Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.1 and 4.1.0 OS:Linux (SuSE Linux 8.2, 9.0 Intel)
Assigned to: CPU Architecture:Any

[16 Jan 2004 7:30] Scott Courtney
Description:
The MySQL command line client repeatably generates a segfault in libc.so.6 
under SuSE Linux 8.2 and 9.0, upon issuance of the "exit" or "quit" commands. 
The client appears to function perfectly except for this problem. I have 
replicated the problem on MySQL alpha 4.1.0 and 4.1.1 on both SuSE versions. 
 
The issue appears to be related to storage of the MySQL command history file 
on exit. I hypothesize this because if I delete the history file before 
running the client, the client will correctly exit and save its history 
exactly once. The segfault always happens if there is a pre-existing history 
file, never happens if there was none. Interestingly, the pre-existing history 
file *is* being correctly read, and commands can be recalled from the previous 
session. 
 
It is possible that this bug is related to #1259 in your database, though the 
symptoms I see are somewhat different than what that user reported. 
 
Here is a gdb trace of the segfault (unfortunately I don't have the debugging 
symbols in my source build this time): 
 
mysql> quit 
 
Program received signal SIGSEGV, Segmentation fault. 
0x40260567 in _int_free () from /lib/i686/libc.so.6 
(gdb) bt full 
#0  0x40260567 in _int_free () from /lib/i686/libc.so.6 
No symbol table info available. 
#1  0x4025f22f in free () from /lib/i686/libc.so.6 
No symbol table info available. 
#2  0x08061dd9 in history_save () 
No symbol table info available. 
#3  0x0806152f in history () 
No symbol table info available. 
#4  0x08058af3 in write_history () 
No symbol table info available. 
#5  0x080529e8 in mysql_end(int) () 
No symbol table info available. 
#6  0x080527ed in main () 
No symbol table info available. 
 
As you can see, the function names support my hypothesis that the client is 
failing when it tries to update the history file. 

How to repeat:
I have built MySQL from source using the following configuration command 
(adjusting the --prefix option per MySQL version): 
 
./configure --prefix=/usr/local/mysql-4.1.1-alpha 
 
Relevant versions of libraries and tools from SuSE 9.0 are as follows: 
 
glibc-2.3.2-88 
readline-4.3-207 
gcc-3.3.1-24 
 
The bug behaves exactly the same under SuSE 8.2 and 9.0, though some of these 
library versions are different, of course. 

Suggested fix:
I am not enough of a C programmer to be much help in debugging this (my last 
serious use of C was under MS-DOS version 5.0, many years ago), but I will be 
glad to do additional testing in my environment if you request it. I regret 
that I no longer have access to a SuSE 8.2 system for testing, but I could 
build one if you need me to do so. 
 
MySQL is a terrific piece of software, and I'll be glad to help in any way I 
can with squashing this bug.
[17 Jan 2004 11:51] MySQL Verification Team
Thank you for writting to us.

We are hoewever unable to repeat the bug.

We tried all variants of histfile location, privieleges etc.

Please try our binary and see if it works.

A version we tried was linked with readline library. 

Check whether yours is linked against libedit.
[28 Apr 2004 16:16] Scott Courtney
Per your request for further testing... 
 
I can confirm that the bug does not occur with MySQL binaries installed at the 
following version levels on SuSE Linux 9.0: 
 
MySQL-devel-4.1.1-0 
mysql-shared-4.0.15-9 
MySQL-server-4.1.1-1 
MySQL-client-4.1.1-0 
 
The SuSE platform for testing was a vanilla install, but updated to the latest 
security patches as of 2004-04-26. The RPMs were obtained from MySQL.com. 
 
Scott
[28 Apr 2004 16:17] Scott Courtney
Also...I believe that my previous version was linked against libedit, as you 
had theorized. Perhaps that is the problem. In any case, the bug is missing 
from the binary installs.
[3 May 2004 10:44] Michael Widenius
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.mysql.com/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Additional info:

A likely cause for this problem is that you have two different version of libmysqlclient.so installed and the client you built was using the wrong version of libmysqlcient.so.

One wat to avoid this problem is to build your binaries with the configure options:
--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static

Regards,
Monty
[4 May 2004 18:09] Scott Courtney
SOLVED: 
 
With SuSE 9.0, the following build-time config options eliminate the segfault 
error in the client. 
 
./configure --without-readline --without-libedit  [....et cetera....] 
 
This forces use of the system readline and libedit instead of the bundled 
libraries. 
 
On the system where this was tested, readline and readline-dev RPMs are 
installed but libedit is not.
[7 Aug 2004 19:48] Sergey Kostyliov
Hmm, according to back trace it seems for me that it the same problem 
as for #4696 http://bugs.mysql.com/bug.php?id=4696