php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42625 When mysql and mysqli enabled both together, php CLI hangs when ZTS is enabled
Submitted: 2007-09-11 18:48 UTC Modified: 2008-03-25 19:14 UTC
Votes:9
Avg. Score:4.8 ± 0.4
Reproduced:9 of 9 (100.0%)
Same Version:8 (88.9%)
Same OS:6 (66.7%)
From: jama at mk dot cvut dot cz Assigned: andrey (profile)
Status: Not a bug Package: MySQL related
PHP Version: 5.2.4 OS: Gentoo/Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jama at mk dot cvut dot cz
New email:
PHP Version: OS:

 

 [2007-09-11 18:48 UTC] jama at mk dot cvut dot cz
Description:
------------
when compiled vanilla php-5.2.4 with this params
./configure --disable-all --enable-maintainer-zts --with-mysqli=/usr/
bin/mysql_config
it's ok

when added mysql support too
./configure --disable-all --enable-maintainer-zts --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config
it's bad even sapi/cli/php -i hangs forever on futex call

strace sapi/cli/php -i
....
write(1, "questions about PHP licensing, p"..., 63questions about PHP licensing, please contact license@php.net.
) = 63
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
futex(0x2adbeb81cac0, FUTEX_WAIT, 2, NULL <unfinished ...>

The same behavior with php5.2-200709110830.


Reproduce code:
---------------
tar xjvf php-5.2.4.tar.bz2
mv php-5.2.4 php-5.2.4-mysqli
cp -r php-5.2.4-mysqli php-5.2.4-mysql-mysqli
cd php-5.2.4-mysql-mysqli
./configure --disable-all --enable-maintainer-zts --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config
make
sapi/cli/php -i #HANGS HERE#

cd ../php-5.2.4-mysqli
./configure --disable-all --enable-maintainer-zts --with-mysqli=/usr/
bin/mysql_config
make
sapi/cli/php -i #DOESN'T HANG HERE#

Diff between those 2 build dirs on my pc..
http://pastebin.com/m9c448da

Portage 2.1.3.9 (default-linux/amd64/2007.0/desktop, gcc-4.2.2-alpha20070905/amd64-vanilla, glibc-2.6.1-r0, 2.6.23-rc5-git1-JaMa x86_64)
=================================================================
System uname: 2.6.23-rc5-git1-JaMa x86_64 AMD Athlon(tm) 64 Processor 3700+
Timestamp of tree: Tue, 11 Sep 2007 10:01:01 +0000
ccache version 2.4 [enabled]
app-admin/eselect-compiler: 2.0.0_rc2-r1
app-shells/bash:     3.2_p17-r1
dev-java/java-config: 1.3.7, 2.0.33-r1
dev-lang/python:     2.4.4-r4, 2.5.1-r2
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 2.0.0_rc4-r1
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.18.50.0.1
sys-devel/gcc-config: 2.0.0_rc1
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.22-r2
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=k8"



Expected result:
----------------
php cli working

Actual result:
--------------
php cli hanging on every occasion

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-12 11:50 UTC] jani@php.net
Why are you using --enable-maintainer-zts in your configure line? You really don't need this for CLI/CGI..
 [2007-09-12 16:15 UTC] Martin dot Jansa at mk dot cvut dot cz
It hangs only with mysql, mysqli AND --enable-maintainer-zts.

I don't want to disable maintainer-zts, because I'm not using only cli/cgi in real installation. :)

This 3 configure parameters is the smallest subset of those I'm normally using.
 [2007-09-13 04:42 UTC] scottmac@php.net
Can you check CGI to see if you can reproduce this.

What version of libmysql are you linking against?
 [2007-09-13 05:27 UTC] jama at mk dot cvut dot cz
/usr/bin/mysql_config --version
5.1.15-beta

but with same mysql and php-5.2.2 it was OK.

CGI I'll try later.
 [2007-09-13 09:38 UTC] jama at mk dot cvut dot cz
if
sapi/cgi/php-cgi -i
can be considered as CGI check, so it doesn't hang
 [2007-09-19 13:38 UTC] jani@php.net
I can not reproduce this. 
 [2007-09-19 13:39 UTC] jani@php.net
# mysql_config --version
5.0.27

 [2007-09-19 13:40 UTC] jani@php.net
Propably some issue with the BETA mysql version used. Assigned to the mysql maintainer. 
 [2007-09-19 14:08 UTC] scottmac@php.net
I can't reproduce with MySQL 5.1.22
 [2007-09-22 08:47 UTC] andrey@php.net
Hi,
- can you try building PHP6?
- if still han gs, can you try building with mysqlnd (PHP6, --with-mysqli=mysqlnd --with-mysql=mysql) and see if there is still a problem

Andrey
 [2007-09-24 09:39 UTC] jama at mk dot cvut dot cz
tested on php6.0-200709240630
mysqli OK
mysql+mysqli BAD
mysql+mysqlng OK

I created simple bash script for building and testing php snapshots for this bug.

It's on
http://pastebin.com/m68372238

Runned in this case as
". ./test.sh php6.0-200709240630.tar.bz2 php6.0-200709240630  php6.0-200709240630"

Manualy killed when php -i was hanging on second test and result looks like this:
# cat php6.0-200709240630.log
OK  php6.0-200709240630-mysqli ./configure --disable-all --enable-maintainer-zts --with-mysqli=/usr/bin/mysql_config
BAD php6.0-200709240630-mysqli-mysql ./configure --disable-all --enable-maintainer-zts --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config
OK  php6.0-200709240630-mysqli-mysqlng ./configure --disable-all --enable-maintainer-zts --with-mysql=mysql --with-mysqli=mysqlnd
 [2007-10-05 12:22 UTC] jama at mk dot cvut dot cz
I have updated mysql to:
mysql_config --version
5.1.22-rc

Downloaded new snapshots and new report seems OK for php..

./test.report.sh
php-5.2.4.log
OK  php-5.2.4-mysqli ./configure --disable-all --enable-maintainer-zts --with-mysqli=/usr/bin/mysql_config
OK  php-5.2.4-mysqli-mysql ./configure --disable-all --enable-maintainer-zts --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config

php5.2-200710051030.log
OK  php5.2-200710051030-mysqli ./configure --disable-all --enable-maintainer-zts --with-mysqli=/usr/bin/mysql_config
OK  php5.2-200710051030-mysqli-mysql ./configure --disable-all --enable-maintainer-zts --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config

php6.0-200710051030.log
OK  php6.0-200710051030-mysqli ./configure --disable-all --enable-maintainer-zts --with-mysqli=/usr/bin/mysql_config
OK  php6.0-200710051030-mysqli-mysql ./configure --disable-all --enable-maintainer-zts --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config
OK  php6.0-200710051030-mysqli-mysqlng ./configure --disable-all --enable-maintainer-zts --with-mysql=mysql --with-mysqli=mysqlnd
 [2007-11-21 19:47 UTC] dirk at bean-it dot nl
I'm experiencing the same problem, but my 2 cents tell me this is only happening on amd64 + mysql + mysqli. My various i386 systems, build with the same configure options have no problems at all. Leaving mysql or mysqli option out results in a fine working php. Enabling them both results in a broken php (ie, no prompt is returned in the cli, and the apache modules works extremely crappy, since tons of new apaches are started and they all hang).

The problem still exists in 5.2.5 and was not in there 5.2.3.

I run Debian 4.0 (x86_64 GNU/Linux) on all systems, with stock kernels (2.6.18)

I'm happy to provide more info, if necessary. Or to post a new bug, if you think this is more appropriate...
 [2007-11-26 15:53 UTC] dirk at bean-it dot nl
I'll have to get back on my previous post, it also happens on i686 :-(

So, when I enable mysql & mysqli, this results in a non working php.
(./configure --with-mysqli=/usr/bin/mysql_config --with-mysql=/usr)

Just enabling mysql or mysqli works fine.
(./configure --with-mysqli=/usr/bin/mysql_config) or (./configure --with-mysql=/usr)

I've compared the mysql libs version on the i686 machines (one does compile a good php, one doesn't) and they are the same.
 [2007-11-27 12:29 UTC] dirk at bean-it dot nl
Here I am again... :-)

Debian posted updated for mysql-5 and it libs today. Installing this resolves my issue, I have a working php 5.2.5 now.

Non working debian mysql-5 version:
ii  libmysqlclient15-dev              5.0.32-7etch1
ii  libmysqlclient15off               5.0.32-7etch1

Working:
ii  libmysqlclient15-dev            5.0.32-7etch3
ii  libmysqlclient15off             5.0.32-7etch3

Cheers,

Dirk
 [2008-01-07 05:43 UTC] s dot s at terra dot com dot br
Same problem since PHP 5.2.3.

My site configuration:

Distro: Slackware Linux 11.0 (will upgrade to 12.0 soon)

# httpd -v
Server version: Apache/2.2.6 (Unix)
Server built:   Dec  9 2007 18:54:29

# php -v
PHP 5.2.5 (cli) (built: Dec  9 2007 21:25:26) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

# /usr/local/mysql/bin/mysql_config --version
5.0.41

-------------------------------

PHP and Apache was compiled by me.
MySQL is the default pre-compiled distribution from MySQL.com web site.

Strace output on cli mode:

lstat64("/root", {st_mode=S_IFDIR|0710, st_size=1176, ...}) = 0
lstat64("/root/-", 0xbfcb65fc)          = -1 ENOENT (No such file or directory)
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
fstat64(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fbe000
read(0, "", 1024)                       = 0
close(0)                                = 0
munmap(0xb7fbe000, 4096)                = 0
munmap(0xb7599000, 266240)              = 0
mmap2(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7599000
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
gettimeofday({1199684414, 364083}, NULL) = 0
gettimeofday({1199684414, 365349}, NULL) = 0
futex(0xb7f655c0, FUTEX_WAIT, 2, NULL <unfinished ...>

p.s. Why it searches for a file called "-" on the current directory??? (see second lstat64)
 [2008-01-07 05:59 UTC] s dot s at terra dot com dot br
It seems a pthread version bug. Checking with gdb the result is:

Starting program: /usr/bin/php 
[Thread debugging using libthread_db enabled]
[New Thread -1218722112 (LWP 24212)]
[New Thread -1219249232 (LWP 24215)]
[Thread -1219249232 (zombie) exited]


Program received signal SIGINT, Interrupt.
[Switching to Thread -1218722112 (LWP 24212)]
0xb7708fd9 in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0

And a backtrace:

(gdb) bt
#0  0xb7708fd9 in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0
#1  0xb7706a64 in _L_mutex_lock_22 () from /lib/tls/libpthread.so.0
#2  0xb7fadaa0 in _dl_runtime_resolve () from /lib/ld-linux.so.2
#3  0xb7da51a1 in my_thread_global_end ()
   from /usr/local/mysql/lib/libmysqlclient_r.so.15
#4  0xb7da51a1 in my_thread_global_end ()
   from /usr/local/mysql/lib/libmysqlclient_r.so.15
#5  0xb7da10b5 in my_end () from /usr/local/mysql/lib/libmysqlclient_r.so.15
#6  0xb7d9a27e in mysql_server_end ()
   from /usr/local/mysql/lib/libmysqlclient_r.so.15
#7  0x081817eb in zm_shutdown_mysqli (type=1, module_number=23, 
    tsrm_ls=0x8600050)
    at /usr/src/network/web/php-5.2.5/ext/mysqli/mysqli.c:676
#8  0x083236fe in module_destructor (module=0x863e220)
    at /usr/src/network/web/php-5.2.5/Zend/zend_API.c:1916
#9  0x08329519 in zend_hash_apply_deleter (ht=0x85ffb80, p=0x863e1f0)
    at /usr/src/network/web/php-5.2.5/Zend/zend_hash.c:611
#10 0x083295d7 in zend_hash_graceful_reverse_destroy (ht=0x85ffb80)
    at /usr/src/network/web/php-5.2.5/Zend/zend_hash.c:646
#11 0x0831e4dd in zend_shutdown (tsrm_ls=0x8600050)
    at /usr/src/network/web/php-5.2.5/Zend/zend.c:733
#12 0x082db92e in php_module_shutdown (tsrm_ls=0x8600050)
    at /usr/src/network/web/php-5.2.5/main/main.c:1887
---Type <return> to continue, or q <return> to quit---
#13 0x083986b9 in main (argc=1, argv=0xbfc5d364)
    at /usr/src/network/web/php-5.2.5/sapi/cli/php_cli.c:1335
 [2008-03-04 09:06 UTC] kalle at addikti dot net
Hello,

Has someone solve this problem?
I just run to it, but I got little different opinion what is causing this. Or im 100% sure that problem is not mysql AND mysqli compiled same time.

I have two identical server's

OS: Debian Etch
MySQL_config: 5.0.32
PHP 5.2.5

Bought server's PHP has compiled with same options..
'./configure' \
'--includedir=/usr/include' \
'--prefix=/home/pete/wwwroot/php' \
'--with-apxs2=/home/pete/wwwroot/bin/apxs' \
'--with-config-file-path=/home/pete/wwwroot/php' \
'--with-mysql=/usr' \
'--with-pgsql' \
'--with-openssl' \
'--with-imap' \
'--with-imap-ssl' \
'--with-xpm-dir' \
'--with-mysqli=/usr/bin/mysql_config' \
'--enable-exif' \
'--enable-ftp' \
'--with-kerberos' \
'--with-mcrypt' \
'--with-gd' \
'--with-jpeg-dir=/usr/lib' \
'--with-png-dir=/usr/lib' \
'--with-mime-magic' \
'--with-zlib-dir=/usr/lib' \
'--with-pdo-mysql=/usr/bin/mysql_config' \
'--with-pdo-sqlite' \
'--with-xmlrpc' \
'--with-ttf' \
'--with-curl' \
'--with-mhash' \
'--enable-soap' \
'--enable-mbstring' \
'--enable-calendar' \
'--enable-gd-native-ttf' \
'--with-freetype-dir=/usr/src/freetype234' \
'--with-gettext' \
'--with-xsl' \
"$@"

Funny think is that this work on other server and not on other.
strace give me same error.

I have also tried this with 5.2.6-RC1.
It works on other and not on other.

So my opinion is that this is not directly PHP problem but it has something to with some library??
Any help will be much pricieted.
 [2008-03-04 09:11 UTC] kalle at addikti dot net
Hello,

And one more thing.
If I compile PHP without path to apxs the CLI will work.
example: ./sapi/cli/php -v
 [2008-03-04 09:20 UTC] kalle at addikti dot net
Hello,

Sorry for spam.
I should read this thread couple of times more.

Problem will solve itself when you rename /lib/tls to /lib/tls.go.fuck.yourself
 [2008-03-25 19:14 UTC] andrey@php.net
Seems wasn't a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 11:01:30 2024 UTC