php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35009 ZTS: Persistent resource destruct crashes when extension is compiled as shared
Submitted: 2005-10-28 19:05 UTC Modified: 2005-11-07 13:36 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: glen at delfi dot ee Assigned: dmitry
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-11-06 (cvs) OS: *
Private report: No CVE-ID:
 [2005-10-28 19:05 UTC] glen at delfi dot ee
Description:
------------
$ php -r 'mysql_pconnect();'
Segmentation fault

you will need to specify proper auth strings for the connection to succeed.

bug is present in php 4.4.0, php 5.0.5 with both ZTS enabled. on same system disabling ZTS with php 4.4.0 the crash didn't occour.

also used php5-STABLE-200510281434 snapshot. and crash was reproducible.


Reproduce code:
---------------
$ gdb --args php -r 'mysql_pconnect();'
GNU gdb 6.3
Copyright 2004 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 "--host= --target=i686-pld-linux"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) run
Starting program: /usr/bin/php -r mysql_pconnect\(\)\;

Program received signal SIGSEGV, Segmentation fault.
0xb7879948 in ?? ()
(gdb) bt
#0  0xb7879948 in ?? ()
#1  0xb7f0d549 in plist_entry_destructor (ptr=0x80dbb00)
    at /home/builder/rpm/BUILD/php5-STABLE-200510281434/Zend/zend_list.c:210
#2  0xb7f0b53f in zend_hash_apply_deleter (ht=0x8052c60, p=0x80e3f40)
    at /home/builder/rpm/BUILD/php5-STABLE-200510281434/Zend/zend_hash.c:574
#3  0xb7f0b790 in zend_hash_graceful_reverse_destroy (ht=0x8052c60)
    at /home/builder/rpm/BUILD/php5-STABLE-200510281434/Zend/zend_hash.c:640
#4  0xb7f0d665 in zend_destroy_rsrc_list (ht=0x8052c60, tsrm_ls=0x804f0a8)
    at /home/builder/rpm/BUILD/php5-STABLE-200510281434/Zend/zend_list.c:240
#5  0xb7f0146a in zend_shutdown (tsrm_ls=0x804f0a8) at /home/builder/rpm/BUILD/php5-STABLE-200510281434/Zend/zend.c:714
#6  0xb7eaa3e3 in php_module_shutdown (tsrm_ls=0x804f0a8)
    at /home/builder/rpm/BUILD/php5-STABLE-200510281434/main/main.c:1529
#7  0x0804be44 in main (argc=3, argv=0xbfcb04a4)
    at /home/builder/rpm/BUILD/php5-STABLE-200510281434/sapi/cli/php_cli.c:1058
(gdb)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-01 11:39 UTC] sniper@php.net
What if you configure the mysql extension as static, does it work then?
 [2005-11-01 16:42 UTC] glen at delfi dot ee
yes. appears so: 
 
$ ./configure --disable-all --with-mysql 
--enable-maintainer-zts --enable-debug 
$ make 
$ ./sapi/cli/php  -r '$r = mysql_pconnect("heart");echo 
"$r\n";'; echo "rc=$?" 
Resource id #4 
rc=0 
$ ./sapi/cli/php -m 
[PHP Modules] 
date 
mysql 
standard 
 
[Zend Modules] 
 
code used: php5-200510281630
 [2005-11-06 15:30 UTC] sniper@php.net
Verified. Reproducing steps:

# ./configure --disable-all --with-mysql=shared --enable-maintainer-zts --enable-debug
# make
# gdb --args sapi/cli/php -dextension_dir=. -dextension=modules/mysql.so -r '$f = mysql_pconnect();'
(gdb) run

 [2005-11-06 15:37 UTC] sniper@php.net
Seems to happen with any shared extension's persistent resources. Dmitry, can you check this out please?
 [2005-11-07 13:36 UTC] dmitry@php.net
Fixed in CVS HEAD, PHP_5_1, PHP_5_0 and PHP_4_4.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 21:01:56 2014 UTC