|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25400 mysql_connect -> Segmentation Fault
Submitted: 2003-09-06 09:04 UTC Modified: 2003-09-10 20:21 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: stephan at wiedner dot cc Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5CVS-2003-09-10 (dev) OS: Debian Woody Kernel:2.4.22
Private report: No CVE-ID: None
 [2003-09-06 09:04 UTC] stephan at wiedner dot cc
Every try to connect to the MySQL Server ends up in a segmentation fault.
When using the Apache2 Module I get the following log-output:
[notice] child pid 25103 exit signal Segmentation fault (11)

Using cli/php i just get "Segmentation fault" - without being any more specific...

This problem occours with:

Apache 2.0.47
MySQL 4.0.14

PHP Configure Options:
  --prefix=/usr/local  \
  --exec-prefix=/usr/local  \
  --bindir=/usr/local/bin  \
  --sbindir=/usr/local/sbin  \
  --libexecdir=/usr/local/libexec  \
  --datadir=/usr/local/share  \
  --sysconfdir=/usr/local/etc  \
  --sharedstatedir=/usr/local/com  \
  --localstatedir=/usr/local/var  \
  --libdir=/usr/local/lib  \
  --includedir=/usr/local/include  \
  --infodir=/usr/local/info  \
  --mandir=/usr/local/man  \
  --with-apxs2=/usr/sbin/apxs  \
  --enable-debug  \
  --with-config-file-path=/usr/local/lib  \
  --enable-safe-mode  \
  --disable-ipv6  \
  --disable-short-tags  \
  --with-dom=/usr/local  \
  --with-xsl=/usr/local   \
  --with-pspell  \
  --enable-dbx  \
  --with-db4=/usr/local/BerkeleyDB.4.1  \
  --with-gd=/usr/local  \
  --with-mysql=/usr/local \
  --with-mysql-sock=/tmp/mysql.sock  \
  --with-pgsql  \
  --with-gettext  \

MySQL Configure Options:
./configure \
  --prefix=/usr/local \
  --enable-dependency-tracking \
  --localstatedir=/home/mysql \
  --enable-assembler \
  --with-unix-socket-path=/tmp/mysql.sock \
  --with-mysqld-user=mysql \

I hope I provided all necessary information and that this isn't a bug but my fault... :)

Reproduce code:
echo 'Trying to connect ... ';
$con = mysql_connect('localhost','user','pass') or die ("Unable to connect ...");
echo "super!";

Expected result:

Actual result:
---- cli backtrace: ----

server:/# gdb ./php
GNU gdb 2002-04-01-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
(gdb) run test2.php
Starting program: /usr/src/WebServer/php-src/sapi/cli/php test2.php
[New Thread 1024 (LWP 784)]
Trying to connect ...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 784)]
0x08319af0 in ?? ()
(gdb) bt
#0  0x08319af0 in ?? ()
#1  0x405f79e0 in _nss_db_getspnam_r () from /lib/
#2  0x405f711e in _nss_db_endservent () from /lib/
#3  0x405f73b3 in _nss_db_getservbyname_r () from /lib/
#4  0x40571a83 in getservbyname_r () from /lib/
#5  0x40571931 in getservbyname () from /lib/
#6  0x401991af in mysql_once_init () from /usr/local/lib/mysql/
#7  0x4019b9d8 in mysql_init () from /usr/local/lib/mysql/
#8  0x080ad624 in php_mysql_do_connect (ht=3, return_value=0x405b94b8, this_ptr=0x0, return_value_used=1, persistent=0)
    at /usr/src/WebServer/php-src/ext/mysql/php_mysql.c:773
#9  0x080ad955 in zif_mysql_connect (ht=3, return_value=0x405b94b8, this_ptr=0x0, return_value_used=1)
    at /usr/src/WebServer/php-src/ext/mysql/php_mysql.c:829
#10 0x08238f70 in zend_do_fcall_common_helper (execute_data=0xbfffd760, op_array=0x405b8b7c)
    at /usr/src/WebServer/php-src/Zend/zend_execute.c:2541
#11 0x08239797 in zend_do_fcall_handler (execute_data=0xbfffd760, op_array=0x405b8b7c)
    at /usr/src/WebServer/php-src/Zend/zend_execute.c:2687
#12 0x08234ba7 in execute (op_array=0x405b8b7c) at /usr/src/WebServer/php-src/Zend/zend_execute.c:1267
#13 0x082127a4 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/WebServer/php-src/Zend/zend.c:1018
#14 0x081cc44b in php_execute_script (primary_file=0xbffffaf4) at /usr/src/WebServer/php-src/main/main.c:1625
#15 0x0824313f in main (argc=2, argv=0xbffffb84) at /usr/src/WebServer/php-src/sapi/cli/php_cli.c:910

---- apache2 backtrace: ----
Starting program: /usr/sbin/httpd -X
[New Thread 1024 (LWP 853)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 853)]
0x082b06c8 in ?? ()
(gdb) bt
#0  0x082b06c8 in ?? ()
#1  0x408ee9e0 in _nss_db_getspnam_r () from /lib/
#2  0x408ee11e in _nss_db_endservent () from /lib/
#3  0x408ee3b3 in _nss_db_getservbyname_r () from /lib/
#4  0x4026ea83 in getservbyname_r () from /lib/
#5  0x4026e931 in getservbyname () from /lib/
#6  0x406331af in mysql_once_init () from /usr/local/lib/mysql/
#7  0x406359d8 in mysql_init () from /usr/local/lib/mysql/
#8  0x40328ac4 in php_mysql_do_connect (ht=3, return_value=0x408a6240, this_ptr=0x0, return_value_used=1, persistent=0)
    at /usr/src/WebServer/php-src/ext/mysql/php_mysql.c:773
#9  0x40328df5 in zif_mysql_connect (ht=3, return_value=0x408a6240, this_ptr=0x0, return_value_used=1)
    at /usr/src/WebServer/php-src/ext/mysql/php_mysql.c:829
#10 0x404b4410 in zend_do_fcall_common_helper (execute_data=0xbfffd600, op_array=0x408a57e0)
    at /usr/src/WebServer/php-src/Zend/zend_execute.c:2541
#11 0x404b4c37 in zend_do_fcall_handler (execute_data=0xbfffd600, op_array=0x408a57e0)
    at /usr/src/WebServer/php-src/Zend/zend_execute.c:2687
#12 0x404b0047 in execute (op_array=0x408a57e0) at /usr/src/WebServer/php-src/Zend/zend_execute.c:1267
#13 0x4048dc44 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/WebServer/php-src/Zend/zend.c:1018
#14 0x404478eb in php_execute_script (primary_file=0xbffff870) at /usr/src/WebServer/php-src/main/main.c:1625
#15 0x404bdbe3 in php_handler (r=0x82aba28) at /usr/src/WebServer/php-src/sapi/apache2handler/sapi_apache2.c:529
#16 0x080aded9 in ap_run_handler (r=0x82aba28) at config.c:194
#17 0x080ae423 in ap_invoke_handler (r=0x82aba28) at config.c:401
#18 0x08097d16 in ap_process_request (r=0x82aba28) at http_request.c:288
#19 0x08093dea in ap_process_http_connection (c=0x82a59f0) at http_core.c:293
#20 0x080b7078 in ap_run_process_connection (c=0x82a59f0) at connection.c:85
#21 0x080b731c in ap_process_connection (c=0x82a59f0, csd=0x82a5918) at connection.c:211
#22 0x080acbc0 in child_main (child_num_arg=0) at prefork.c:694
#23 0x080acc7c in make_child (s=0x818cb18, slot=0) at prefork.c:734
#24 0x080acd71 in startup_children (number_to_start=5) at prefork.c:806
#25 0x080ad06c in ap_mpm_run (_pconf=0x8189a58, plog=0x81c1b38, s=0x818cb18) at prefork.c:1022
#26 0x080b25ae in main (argc=2, argv=0xbffffbc4) at main.c:660


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-07 02:38 UTC]
This is not a PHP problem, looks like your mysql configuration is  
borked. Try to install a 4.0.14 binary from (or 4.0.15 which  
should be announced within the next days).  
 [2003-09-10 15:51 UTC] stephan at wiedner dot cc

In the meanwhile I tried the 4.0.14 Binary Dist. of mysql and the new 4.0.15 binaries.
I also tried again with the BETA version and the latest CVS Version. still the same problem....

Here a backtrace from the 5CVS-2003-09-10 cli/php trying to connect to the 4.0.15 mysql Server:
(gdb) run test2.php
Starting program: /usr/src/WebServer/php-src/sapi/cli/php test2.php
[New Thread 1024 (LWP 7916)]
Jetzt gehts lohos!
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 7916)]
0x08341ea8 in ?? ()
(gdb) bt
#0  0x08341ea8 in ?? ()
#1  0x405d59e0 in _nss_db_getspnam_r () from /lib/
#2  0x405d511e in _nss_db_endservent () from /lib/
#3  0x405d53b3 in _nss_db_getservbyname_r () from /lib/
#4  0x4054fa83 in getservbyname_r () from /lib/
#5  0x4054f931 in getservbyname () from /lib/
#6  0x0824b117 in mysql_once_init ()
#7  0x0824b04f in mysql_init ()
#8  0x080b3014 in php_mysql_do_connect (ht=3, return_value=0x405974b8, this_ptr=0x0, return_value_used=1, persistent=0)
    at /usr/src/WebServer/php-src/ext/mysql/php_mysql.c:773
#9  0x080b3345 in zif_mysql_connect (ht=3, return_value=0x405974b8, this_ptr=0x0, return_value_used=1)
    at /usr/src/WebServer/php-src/ext/mysql/php_mysql.c:829
#10 0x0823ee30 in zend_do_fcall_common_helper (execute_data=0xbfffd760, op_array=0x40596b7c)
    at /usr/src/WebServer/php-src/Zend/zend_execute.c:2541
#11 0x0823f657 in zend_do_fcall_handler (execute_data=0xbfffd760, op_array=0x40596b7c)
    at /usr/src/WebServer/php-src/Zend/zend_execute.c:2687
#12 0x0823aa67 in execute (op_array=0x40596b7c) at /usr/src/WebServer/php-src/Zend/zend_execute.c:1267
#13 0x082182a4 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/WebServer/php-src/Zend/zend.c:1010
#14 0x081d1f2b in php_execute_script (primary_file=0xbffffaf4) at /usr/src/WebServer/php-src/main/main.c:1625
#15 0x08248fdf in main (argc=2, argv=0xbffffb84) at /usr/src/WebServer/php-src/sapi/cli/php_cli.c:910
 [2003-09-10 20:21 UTC]
The backtrace shows it happens inside the mysql libs -> not PHP bug. (report to Mysql)

 [2003-09-21 09:08 UTC] hrmn at gmx dot de
I bet your configuration is broken - this is not a bug. I run 4.0.15 under 
php4 and php5 without any problem. 
  $link = mysql_connect("localhost", "testuser", ""); 
  printf("PHP Version: %s\n", phpversion());  
  printf("Zend Version: %s\n", zend_version());  
  printf("client lib version: %s\n",  mysql_get_client_info()); 
  printf("server version: %s\n", mysql_get_server_info()); 
PHP Version: 5.0.0b2-dev 
Zend Version: 2.0.0-dev 
client lib version: 4.0.15 
server version: 4.0.15-debug-log
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Mar 29 20:03:46 2023 UTC