Bug #27168 Unreliable with --with-mysql-ldflags=-all-static
Submitted: 15 Mar 2007 11:12 Modified: 5 Jul 2007 19:45
Reporter: James Green Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:5.0.41, 5.0.37 OS:Linux (Debian 3.1 Linux 2.6)
Assigned to: CPU Architecture:Any
Tags: regression

[15 Mar 2007 11:12] James Green
Description:
I upgraded from source compiled 5.0.26a to 5.0.37 and immediately the binaries were hanging on startup using the recommended compilation options as found on your website (plus some -mcpu=pentium pro optimisations).

It would apparently start, but not create a socket or pid. Logs indicated it would running. After several recompilations without optimisations I got it to create the socket and pid, but the client would hang on connection, causing the server to stop, requiring kill -9 <pids> to stop the server.

Only after removing --with-mysql-ldflags=-all-static does the problem get resolved. I have it running and seems okay so far.

Debian 3.1 with updates, Linux 2.6.18.

How to repeat:
#!/bin/bash
CFLAGS="-O3 -mcpu=pentiumpro" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti -mcpu=pentiumpro" \
./configure \
--prefix=/opt/mysql-5.0.37 \
--enable-assembler \
--enable-thread-safe-client \
--with-mysql-ldflags=-all-static

Suggested fix:
Remove --with-mysql-ldflags=-all-static from the notes. I'm assuming here the flag is either outdated or the build doesn't agree with the libaries for other reasons in recent builds.
[28 Mar 2007 9:31] Martin Gallagher
I'm having this problem with a custom compile of MySQL (both 5.0.37 and 5.0.38 tested) with the addition of the Sphinx full text storage engine on CentOS 4.4.

The bahaviour of MySQL with "--with-mysql-ldflags=-all-static" results in MySQL restarting and spawning several mysqld processes.

Removing "--with-mysql-ldflags=-all-static" solves this issue.
[2 Apr 2007 9:58] CJS 2895
I have duplicated the problem on my system. When compiling with these flags:

CFLAGS="-O3 -pipe -s" CXX=gcc CXXFLAGS="-O3 \
-pipe -s -felide-constructors -fno-exceptions -fno-rtti" ./configure \
--enable-assembler --disable-largefile \
--with-charset=utf8 --with-extra-charsets=none --without-debug \
--without-docs --without-man --without-geometry \
--with-client-ldflags=-all-static \
--enable-assembler --with-mysqld-ldflags=-all-static \
--enable-thread-safe-client --without-ssl --with-plugins=innobase \
--with-collation=utf8_unicode_ci --prefix=/usr/local/mysql \
--disable-dependency-tracking --with-mysqld-user=mysql

Removing the --with-mysqld-ldflags=-all-static option will cause the binary to work correctly. The last version I had where the flag worked was 5.0.20 - it may work in more recent versions, but 5.0.20 was the last version I used.

System is Linux x86 runing Debian Sarge with GCC 3.4.4 20050314 and glibc 2.3.2 (both provided by the Debian distribution)
[26 Apr 2007 13:04] Valeriy Kravchuk
Thank you for a problem report. Please, send the results of:

getconf GNU_LIBC_VERSION
getconf GNU_LIBPTHREAD_VERSION
uname -a

from your system.
[26 Apr 2007 13:22] James Green
jmkg@sarge:~$ getconf GNU_LIBC_VERSION
glibc 2.3.2
jmkg@sarge:~$ getconf GNU_LIBPTHREAD_VERSION
NPTL 0.60
jmkg@sarge:~$ uname -a
Linux sarge 2.6.20.3 #1 SMP PREEMPT Thu Mar 15 10:11:12 GMT 2007 i686 GNU/Linux
[26 Apr 2007 13:54] Martin Gallagher
# getconf GNU_LIBC_VERSION
glibc 2.3.4

# getconf GNU_LIBPTHREAD_VERSION
NPTL 2.3.4

# uname -a
Linux xxx.static.reverse.layeredtech.com 2.6.9-42.0.10.ELsmp #1 SMP Tue Feb 27 10:11:19 EST 2007 i686 athlon i386 GNU/Linux
[23 May 2007 10:35] Valeriy Kravchuk
Please, try to repeat with a newer version, 5.0.41, and inform about the results.
[23 May 2007 11:28] James Green
Built 5.0.41. mysql client hung on the third connection after entering my password.

/etc/init.d/mysql stop failed to stop server.
Had to killall -9 mysqld_safe & killall -9 mysqld

Started it up again. Did nothing more. Tried to stop it, failed again.

I have again rolled back to 5.0.26 which seems stable.
[23 May 2007 13:54] Martin Gallagher
I too repeated the bug with mysql-5.0.40 from ftp://ftp.mysql.com/pub/mysql/src/

The bug does NOT occur on another setup (Clovertown based):
# getconf GNU_LIBC_VERSION
glibc 2.5

# getconf GNU_LIBPTHREAD_VERSION
NPTL 2.3.4

# uname -a
Linux *host* 2.6.18-8.el5 #1 SMP Thu Mar 15 19:46:53 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

With the config as follows:
CFLAGS="-O3 -march=nocona -msse2 -msse3" CXX="gcc" \
CXXFLAGS="-O3 -march=nocona -msse2 -msse3 -felide-constructors -fno-exceptions -fno-rtti" \
CXXLDFLAGS="" \
./configure --prefix=/usr/local/mysql \
	 --with-client-ldflags=-all-static \
	 --with-mysqld-ldflags=-all-static \
	 --disable-shared \
	 --with-fast-mutexes \
	 --with-innodb \
	 --with-federated-storage-engine \
	 --enable-assembler \
	 --enable-thread-safe-client \
	 --with-readline \
	 --with-big-tables \
	 --enable-local-infile \
	 --with-mysqld-user=mysql \
	 --with-charset=utf8 \
	 --with-collation=utf8_general_ci \
	 --with-extra-charsets=none \
	 --without-uca \
	 --without-docs \
	 --without-bench \
	 --without-man \
	 --without-query-cache \
	 --without-debug \
	 --with-sphinx-storage-engine \
	 --with-pic
[23 May 2007 13:55] Martin Gallagher
Just to ammend the NPTL version in the above post, NPTL is in fact version 2.5
[26 May 2007 22:33] Laurent Chardin
I could also reproduce the problem:

* former release : 5.0.26, compiled from source
* new release : 5.0.41, compiled from source

The 5.0.26 works fine, i was planning to update the version.

same configure used in both cases (changing --prefix only):
CFLAGS="-O3 -march=pentiumpro" \
CXX=gcc \
CXXFLAGS="-O3 -march=pentiumpro -felide-constructors -fno-exceptions -fno-rtti" \
./configure \
--prefix=/usr/local/mysql-5.0.41 \
--localstatedir=/var/lib/mysql-5.0 \
--enable-assembler \
--enable-thread-safe-client \
--with-server-suffix=-wcube \
--with-charset=latin1 \
--with-extra-charset=all \
--with-mysqld-user=mysql \
--with-zlib-dir=/usr \
--with-big-tables \
--with-mysld-ldflags=-all-static \
--with-unix-socket-path=/var/run/mysqld-5.0/mysql.sock

the 5.0.41 version starts, doesn't create any sock file. I have to kill the remaining process by hand (killall..)

Removing "--with-mysld-ldflags=-all-static \" seems to solve the problem.

server:~/source/mysql# getconf GNU_LIBC_VERSION
glibc 2.3.6
server:~/source/mysql# getconf GNU_LIBPTHREAD_VERSION
NPTL 2.3.6
server:~/source/mysql# uname -a
Linux krypton 2.6.18-3-686 #1 SMP Mon Dec 4 16:41:14 UTC 2006 i686 GNU/Linux
[27 May 2007 17:43] Nicklas Bondesson
I'm having a similar problem with mysql 5.0.33 on Debian 4.0 (Etch).

Mysql is starting and seems to run fine but then it dies.

getconf GNU_LIBC_VERSION
glibc 2.3.6

getconf GNU_LIBPTHREAD_VERSION
NPTL 2.3.6

uname:
Linux server03 2.6.20.7 #3 Sun May 27 14:45:21 CEST 2007 i686 GNU/Linux

Compiled from source:

CFLAGS="-O3 -march=pentiumpro" CXX=gcc CXXFLAGS="-O3 -march=pentiumpro \
   -felide-constructors -fno-exceptions -fno-rtti" ./configure \
   --prefix=/usr/local/mysql --enable-assembler \
   --with-mysqld-ldflags=-all-static

Error in log:

mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=0
read_buffer_size=258048
max_used_connections=0
max_connections=256
threads_connected=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 64510 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=(nil)
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0xae4dfac8, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x80dfcc9
0x8395176
0x838fe70
0x830b85d
0x82b6775
0x82d1736
0x8213e08
0x83906f4
0x83bfe0a
New value of fp=(nil) failed sanity check, terminating stack trace!
[28 May 2007 9:01] Nicklas Bondesson
I can reproduce the same problem with 5.0.41.
[29 May 2007 19:35] Nicklas Bondesson
I have tried to pass "-L/lib/tls" to LDFLAGS to configure and the recompile. The server doesnt show any trace of crashing in the logs, but it fails to start.

What should I try next to get this right?
[5 Jun 2007 19:45] Valeriy Kravchuk
This can be a duplciate of bug #28690. Please, check if new patch for that bugs solves your problem.
[6 Jun 2007 11:23] Nicklas Bondesson
I tried putting user=root in my.conf and now the server starts up. Seems like the patch will solve parts of my problem too.

The last issue i'm having is that mysql always uses LinuxThreads when linked staticly. Debian Etch uses both LinuxThreads and NPTL.

Which is the preferred library on terms of stability, performance etc? I guess NPTL is the one use on a 2.6.x kernel? If so, how can I force linking agains the NPTL libs?

Nicklas
[6 Jun 2007 11:46] Nicklas Bondesson
Extra notes:

Is the following correct?

I see multiple mysqld processes with "ps -ef" = LinuxThreads
Only one process = NPTL?
[5 Jul 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".