|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16806 mysql_connect deadlocks on gethostbyname
Submitted: 2002-04-24 14:56 UTC Modified: 2002-04-29 19:30 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ryan at estara dot com Assigned:
Status: Closed Package: Apache2 related
PHP Version: 4.2.0 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ryan at estara dot com
New email:
PHP Version: OS:


 [2002-04-24 14:56 UTC] ryan at estara dot com
Testing is simple.  Make sure nscd is not running on the machine and that the mysql server is not in the hosts file
but is in DNS. 

Test page.
$result=mysql_query("select FirstName from Users");
while ( $row=mysql_fetch_row($result)) {
echo ("$row[0]\n");

Standalone it works fine.  When run through the webserver
it hangs forever getting stuck in the gethostbyname from
the mysql_connect.  I even changed the libmysqlclient 
libary to the libmysqlclient_r library in the configure and verified it was being used with a ldd of

The webserver is apache 2.0.35 configured with these options:
./configure --prefix=/prod/apache --enable-layout=Apache --enable-ssl --enable-vhost-alias --enable-proxy --enable-rewrite --enable-so --with-mpm=worker --disable-userdir

The php module is configured with:
./configure  --prefix=/prod/apache/php --with-apxs2=/prod/apache/bin/apxs --with-openssl --with-zlib --with-gd --with-java=/usr/java --with-mysql=/prod/mysql --with-readline --enable-memory-limit

It will work if nscd is on, or if /etc/hosts contains the name of the machine that needs to be resolved.

#0  0x402bdba5 in __sigsuspend (set=0x40b3236c) at ../sysdeps/unix/sysv/linux/sigsuspend.c:45
#1  0x402821d9 in __pthread_wait_for_restart_signal (self=0x40b34be0) at pthread.c:969
#2  0x40283a2c in __pthread_lock (lock=0x4001649c, self=0x40b34be0) at spinlock.c:149
#3  0x40280d46 in __pthread_mutex_lock (mutex=0x4001648c) at mutex.c:109
#4  0x403a8e40 in _dl_open (file=0x40b3262c "", mode=1, caller=0x0) at dl-open.c:401
#5  0x403a9cd1 in do_dlopen (ptr=0x40b325fc) at dl-libc.c:78
#6  0x4000d7c3 in _dl_catch_error (objname=0x40b325f4, errstring=0x40b325f8, operate=0x403a9cb0 <do_dlopen>, args=0x40b325fc)
    at dl-error.c:152
#7  0x403a9b7c in __libc_dlopen (__name=0x40b3262c "") at dl-libc.c:42
#8  0x4038aeef in __nss_lookup_function (ni=0x8130940, fct_name=0x403be4ee "gethostbyname_r") at nsswitch.c:340
#9  0x4038b911 in __nss_next (ni=0x40b326dc, fct_name=0x403be4ee "gethostbyname_r", fctp=0x40b326e0, status=-1, all_values=0)
    at nsswitch.c:194
#10 0x4038e1dd in __gethostbyname_r (name=0x82322fc "", resbuf=0x40b3316c, buffer=0x40b3296c "\177", 
    buflen=2048, result=0x40b3271c, h_errnop=0x40b32768) at ../nss/getXXbyYY_r.c:215
#11 0x405da13c in my_gethostbyname_r () from /prod/mysql/lib/mysql/
#12 0x405d1f69 in mysql_real_connect () from /prod/mysql/lib/mysql/
#13 0x4049b0ea in php_mysql_do_connect (ht=3, return_value=0x8236ccc, this_ptr=0x0, return_value_used=1, tsrm_ls=0x81bcdc8, 
    persistent=0) at php_mysql.c:662
#14 0x4049b2e4 in zif_mysql_connect (ht=3, return_value=0x8236ccc, this_ptr=0x0, return_value_used=1, tsrm_ls=0x81bcdc8)
    at php_mysql.c:714
#15 0x404652e8 in execute (op_array=0x8232294, tsrm_ls=0x81bcdc8) at ./zend_execute.c:1598
#16 0x40473f92 in zend_execute_scripts (type=8, tsrm_ls=0x81bcdc8, retval=0x0, file_count=3) at zend.c:810
#17 0x4048163a in php_execute_script (primary_file=0x40b348bc, tsrm_ls=0x81bcdc8) at main.c:1381
#18 0x4047df8d in php_output_filter (f=0x822d290, bb=0x822d4a0) at sapi_apache2.c:401
#19 0x080aa99f in ap_pass_brigade (next=0x822d290, bb=0x822d380) at util_filter.c:534
#20 0x080b0a5b in default_handler (r=0x81fbe60) at core.c:3247
#21 0x080a1236 in ap_run_handler (r=0x81fbe60) at config.c:193
#22 0x080a16a1 in ap_invoke_handler (r=0x81fbe60) at config.c:373
#23 0x0808a5d7 in ap_process_request (r=0x81fbe60) at http_request.c:261
#24 0x08086cb5 in ap_process_http_connection (c=0x81c1428) at http_core.c:291
#25 0x080a9372 in ap_run_process_connection (c=0x81c1428) at connection.c:85
#26 0x0809e876 in process_socket (p=0x81c1318, sock=0x81c1350, my_child_num=0, my_thread_num=0, bucket_alloc=0x81bf2a8)
    at worker.c:613
#27 0x0809ed73 in worker_thread (thd=0x8142590, dummy=0x81bcdc8) at worker.c:886
#28 0x4003ae34 in dummy_worker (opaque=0x8142590) at thread.c:127
#29 0x4027fc6f in pthread_start_thread (arg=0x40b34be0) at manager.c:284
#30 0x4027fd5f in pthread_start_thread_event (arg=0x40b34be0) at manager.c:308


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-29 14:19 UTC] ryan at estara dot com
changed OS to linux, didn't see it appearing in the bug database when I did searches.
 [2002-04-29 19:30 UTC]
Most likely the same issue as was with all the other mysql
problems reported. Get
and replace the configure file with it. 


PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 08:01:29 2023 UTC