Bug #37414 mysqldump segmentation fault
Submitted: 15 Jun 2008 15:50 Modified: 25 Oct 2018 6:37
Reporter: talen xu Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.1.26 OS:Linux
Assigned to: CPU Architecture:Any

[15 Jun 2008 15:50] talen xu
Description:
 built this with the following configure command: 

CFLAGS="-O3" CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --localstatedir=/data/mysql/data --enable-assembler --with-charset=utf8 --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-innodb --with-plugins=partition 

Here is my gcc version: 
lab2:/usr/local/mysql/bin# gcc --version 
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) 

When I run mysqldump here is the output: 
lab2:/usr/local/mysql/bin# ./mysqldump 
Segmentation fault 

When I run this through gdb I get: 
(gdb) run 
Starting program: /usr/local/mysql/bin/mysqldump 
Failed to read a valid object file image from memory. 

Program received signal SIGSEGV, Segmentation fault. 
__errno_location () at errno.c:30 
30 errno.c: No such file or directory. 
in errno.c 

How to repeat:
The solution in this case was to remove 
the "--with-client-ldflags=-all-static " option from the configure command.

for mysql5.1.  How can static compiler ?
[16 Jun 2008 16:49] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior with current development sources. Please indicate minor version of MySQL 5.1 you use.
[17 Jun 2008 1:30] talen xu
MySQL 5.1.22 5.1.23 5.1.24.I have been compiling these
[17 Jun 2008 19:02] Valeriy Kravchuk
Please, try to repeat with a newer version, 5.1.25, and inform about the results.
[20 Jun 2008 17:44] talen xu
[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc/client]# uname -a
Linux NBCTC-DB_USER-S4 2.6.9-67.0.4.ELsmp #1 SMP Fri Jan 18 05:00:00 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc/client]# gcc -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)

[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc/client]# cat /etc/redhat-release 
Red Hat Enterprise Linux AS release 4 (Nahant Update 6)

[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc/client]# /lib/libc.so.6 
GNU C Library stable release version 2.3.4, by Roland McGrath et al

[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc]# ./configure   --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/var --enable-assembler  --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc]# make
[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc]# cd client
[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc/client]# ./mysqldump 
Segmentation fault
[root@NBCTC-DB_USER-S4:7.130 ~/mysql-5.1.25-rc/client]# ./mysql_upgrade
Segmentation fault
[19 Jul 2008 14:27] Valeriy Kravchuk
Please, try to repeat with a newer version, 5.1.26, and inform about the results.
[19 Jul 2008 15:11] talen xu
I've tested in 5.1.26, but still the same mistakes
[22 Jul 2008 20:08] Hartmut Holzgraefe
Verified, could only reproduce this with exactly the same compiler version though ...
[22 Jul 2008 20:38] Hartmut Holzgraefe
(gdb) bt
#0  __errno_location () at errno.c:30
#1  0x080a12e3 in __xstat64 ()
#2  0x080687de in my_stat ()
#3  0x080605ad in search_default_file_with_ext ()
#4  0x080610f7 in my_search_option_files ()
#5  0x08061457 in load_defaults ()
#6  0x080538ad in main ()
[6 Mar 2009 3:08] Alex Alex
version 5.1.30 - same problem

Built this with the following configure command: 

CFLAGS="-O3 -mpentiumpro"
CXX=gcc
CXXFLAGS="-O3 -mpentiumpro -mstack-align-double -felide-constructors -fno-exceptions -fno-rtti"

./configure --prefix=/usr/local/mysql --with-mysqld-user=mysql --with-unix-socket-path=/tmp/mysql.sock --localstatedir=/usr/local/mysql/data --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-assembler --disable-shared --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --without-debug --without-bench --without-docs --without-man

Here is my gcc version: 

server:/# gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

When I run mysqldump here is the output: 

server: /usr/local/mysql/bin# ./mysqldump 
Segmentation fault
[22 Jul 2011 18:34] zhiwen xiao
do not link -lpthread, example:

demo.c:
#include <errno.h>
#include <stdio.h>

int main()  
{
    errno = 5;
    printf("errno(0x%x) = %d\n", &errno, errno); 
    return 0;
}
gcc -o demo demo.c -static -lpthread
./demo 
Segmentation fault (core dumped)

use --with-client-ldflags=-static or fix client/Makefile.in can work:

diff -Nur client/Makefile.in.OLD client/Makefile.in
--- client/Makefile.in.OLD      2011-07-23 02:16:17.000000000 +0800
+++ client/Makefile.in  2011-07-23 02:18:17.000000000 +0800
@@ -110,7 +110,7 @@
 am_mysqldump_OBJECTS = mysqldump.$(OBJEXT) my_user.$(OBJEXT) \
        mf_getdate.$(OBJEXT)
 mysqldump_OBJECTS = $(am_mysqldump_OBJECTS)
-mysqldump_LDADD = $(LDADD)
+mysqldump_LDADD = @CLIENT_EXTRA_LDFLAGS@ $(top_builddir)/libmysql/libmysqlclient.la
 mysqldump_DEPENDENCIES = $(am__DEPENDENCIES_1) \
        $(top_builddir)/libmysql/libmysqlclient.la
 am_mysqlimport_OBJECTS = mysqlimport-mysqlimport.$(OBJEXT)
[22 Jul 2011 20:43] zhiwen xiao
diff -Nur client/Makefile.in.OLD client/Makefile.in
--- client/Makefile.in.OLD    2011-07-22 12:50:26.000000000 +0800
+++ client/Makefile.in  2011-07-22 13:18:30.000000000 +0800
@@ -488,7 +488,7 @@
                                -I$(top_srcdir)/regex \
                                 $(openssl_includes)
 
-LDADD = @CLIENT_EXTRA_LDFLAGS@ $(CLIENT_THREAD_LIBS) \
+LDADD = @CLIENT_EXTRA_LDFLAGS@ \
                                $(top_builddir)/libmysql/libmysqlclient.la
 
 noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \
[25 Oct 2018 6:37] Erlend Dahl
This MySQL version is obsolete.