php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34012 PHP segfaults when connecting to MySQL
Submitted: 2005-08-05 19:20 UTC Modified: 2005-08-06 21:00 UTC
From: bjorn dot malmberg at gmail dot com Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.4.0 OS: Debian Sarge 3.1
Private report: No CVE-ID: None
 [2005-08-05 19:20 UTC] bjorn dot malmberg at gmail dot com
Description:
------------
PHP segfaults on my Debian 3.1 machine when trying to connect to MySQL.

MySQL version: 4.1.13-standard
Apache version: 1.3.31
PHP version: 4.4.0

PHP configline: 
./configure  --with-mysql=/usr/local/mysql --enable-track-vars --enable-xslt --with-xslt-sablot --enable-mbstring --with-apxs=/etc/apache/bin/apxs --with-gettext=/usr/bin --enable-sockets --with-gd --with-jpeg-dir=/usr/lib --with-zlib-dir=/usr/include --with-imagick --enable-exif --enable-sockets --enable-posix --with-iconv

Backtrace:
#0  0x4010139b in mallopt () from /lib/libc.so.6
#1  0x4010015f in free () from /lib/libc.so.6
#2  0x4033179c in _efree (ptr=0x812ec1c) at /usr/src/php/php-4.4.0/Zend/zend_alloc.c:265
#3  0x40290e27 in _close_mysql_link (rsrc=0x812f344) at /usr/src/php/php-4.4.0/ext/mysql/php_mysql.c:297
#4  0x40343434 in list_entry_destructor (ptr=0x812f344) at /usr/src/php/php-4.4.0/Zend/zend_list.c:177
#5  0x403423c9 in zend_hash_apply_deleter (ht=0x40632680, p=0x812a73c) at /usr/src/php/php-4.4.0/Zend/zend_hash.c:611
#6  0x403424ef in zend_hash_graceful_reverse_destroy (ht=0x40632680) at /usr/src/php/php-4.4.0/Zend/zend_hash.c:677
#7  0x40343535 in zend_destroy_rsrc_list (ht=0x40632680) at /usr/src/php/php-4.4.0/Zend/zend_list.c:233
#8  0x40336d93 in shutdown_executor () at /usr/src/php/php-4.4.0/Zend/zend_execute_API.c:211
#9  0x4033e5cd in zend_deactivate () at /usr/src/php/php-4.4.0/Zend/zend.c:693
#10 0x40319085 in php_request_shutdown (dummy=0x0) at /usr/src/php/php-4.4.0/main/main.c:997
#11 0x40356475 in apache_php_module_main (r=0x8125b6c, display_source_mode=0)
    at /usr/src/php/php-4.4.0/sapi/apache/sapi_apache.c:60
#12 0x40356e02 in send_php (r=0x8125b6c, display_source_mode=0, filename=0x0)
    at /usr/src/php/php-4.4.0/sapi/apache/mod_php4.c:627
#13 0x40356e51 in send_parsed_php (r=0x8125b6c) at /usr/src/php/php-4.4.0/sapi/apache/mod_php4.c:642
#14 0x0807aad9 in ap_invoke_handler ()
#15 0x080912bc in process_request_internal ()
#16 0x08091326 in ap_process_request ()
#17 0x080879a0 in child_main ()
#18 0x08087b51 in make_child ()
#19 0x08087ccc in startup_children ()
#20 0x080883ed in standalone_main ()
#21 0x08088c5c in main ()

I guess this means that PHP doesn't like the version of libc that Sarge is using huh?

Reproduce code:
---------------
<?php
$link = mysql_connect('localhost', 'root', '');
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-05 19:36 UTC] tony2001@php.net
Could you test it on another machine (that uses something different than Sarge)? That would answer your question, obviuosly.
 [2005-08-05 19:52 UTC] bjorn dot malmberg at gmail dot com
No I can't... This is the only machine I have with Linux on.

I upgraded this machine from Debian 3.0 to 3.1, unfortunately I also upgraded PHP (4.3.11-4.4.0), MySQL (4.0.12?-4.1.13) and Apache (1.3.29-1.3.31) at the same time, so I can't be 100% sure that the cause is the upgrade to Sarge.

Both Apache and MySQL by themselves works as expected.

For now I could "downgrade" this machine to 3.0 again, but that wouldn't solve the problem for others with 3.1...
 [2005-08-06 00:07 UTC] sniper@php.net
1) What compiler are you using?
2) Where did you get MySQL?

 [2005-08-06 12:34 UTC] derick@php.net
If you're using Debian's mysql package, try upgrading it. I had strange segfaults with some older versions that were solved by upgrading to the latest package.
 [2005-08-06 14:45 UTC] bjorn dot malmberg at gmail dot com
Compiler:
qnlidev01:~# gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)

I downloaded MySQL from the mysql.com site, it isn't from the Debian apt system. I have the MySQL header files in /usr/local/mysql/include as shown in the configline of PHP (--with-mysql=/usr/local/mysql)
 [2005-08-06 20:10 UTC] sniper@php.net
Try upgrading your GCC to something up-to-date..

 [2005-08-06 20:41 UTC] bjorn dot malmberg at gmail dot com
Upgraded to version 3.3.5 (seems to be the latest in apt), recompiled Apache and PHP and Apache still segfaults when I try to connect to MySQL...

qnlidev01:/usr/src/php/php-4.4.0# gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.5 (Debian 1:3.3.5-13)
 [2005-08-06 20:51 UTC] bjorn dot malmberg at gmail dot com
Wrong by me. Sorry about that, I forgot to do a make clean before recompiling, this time it worked! No segfault, seems like Debian should upgrade gcc when doing a dist-upgrade to a newer version with newer versions of gcc.

Thanks a lot! It's now working and you can close this ticket!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC