|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18564 PHP 4.2.1+ hangs on certain pages
Submitted: 2002-07-25 08:30 UTC Modified: 2002-08-27 01:00 UTC
Avg. Score:4.2 ± 0.9
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: james at stealthnet dot co dot uk Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 4.2.2 OS: FreeBSD 4.5
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: james at stealthnet dot co dot uk
New email:
PHP Version: OS:


 [2002-07-25 08:30 UTC] james at stealthnet dot co dot uk
I believe that after several hours of head-scratching I've located a problem that causes one entire website to stop loading (all pages), and one additional unrelated script to experience the same problem. Here goes...

We were informed that one of our domains had stopped responding. We checked, and we were getting zero bytes returned to the browser. Sometimes even Apache's error/access logs were failing to log our accesses. Other sites on the same server were working fine.

Then a few hours later, without any intervention from us, we discovered that the site was back up.

Then a few days later, it was back down again. We checked the server, and we had several httpds that were busy but hung. The load on the machine is usually 0.00 (very light), but now it was close to 2.00, most of which was down to mysqld for some reason. We ran a thorough check over the databases and found no problems.

Several head-scratching hours later of watching the site go down, come up, etc., we recompiled the whole lot and rebooted. Still no change. And then we discovered today about the unrelated web page that was also hanging.

So I took down apache, let the load drop to 0.25, then ran php -f <the script that hangs> and indeed it was hanging still. Then PHP spewed out numerous recursive calls to free() and then segfaulted.

I repeated the the cgi test on a dev box, and it worked. I found out that the cgi on the production box that didn't work was 4.2.1, the dev box's was 4.2.0.

So I installed 4.2.0 as an apache module on our dev box, and indeed the full site came back up. I'm therefore of the belief that PHP 4.2.1+ is sometimes hanging on pages accessing a MySQL database.

I've spoken to someone else, who's telling me he's had the same problem, but on a Linux server whereas his FreeBSD box was fine with it. He's had to downgrade PHP to 4.1.2.

I shall follow this report up with a link to the script as a .phps, and hopefully the database it's supposed to work on (it outputs the database in XML) once I get clearance. The unrelated entire site also works on a mysql database on every page view, however it uses a different database.

All very bizarre, but they all worked perfectly prior to installing 4.2.1+.

Hope to follow this up in a few hours with more details and testcase.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-26 01:56 UTC]
What were the segfault errors?
 [2002-07-26 05:23 UTC] james at stealthnet dot co dot uk
Trying to reproduce this but it is very random.

FWIW, the site ( is currently down due to the hanging, and a ps ax shows the following:

 8260  ??  Ss     0:10.06 /usr/local/sbin/httpd
 8262  ??  I     22:11.14 /usr/local/sbin/httpd
 8265  ??  I      1:51.65 /usr/local/sbin/httpd
 8267  ??  I     43:36.37 /usr/local/sbin/httpd
 8269  ??  I      1:33.23 /usr/local/sbin/httpd
 8273  ??  I      8:22.31 /usr/local/sbin/httpd
 8294  ??  I      1:32.05 /usr/local/sbin/httpd
 8342  ??  I      0:26.78 /usr/local/sbin/httpd
 8460  ??  I      5:23.44 /usr/local/sbin/httpd
 8470  ??  I      5:38.83 /usr/local/sbin/httpd
 8494  ??  I      1:57.36 /usr/local/sbin/httpd
 8525  ??  I      0:58.25 /usr/local/sbin/httpd
 8539  ??  I      6:53.54 /usr/local/sbin/httpd
 8740  ??  I      1:31.74 /usr/local/sbin/httpd
 8839  ??  I      3:34.29 /usr/local/sbin/httpd
 9012  ??  I     23:09.84 /usr/local/sbin/httpd
 9083  ??  I      2:21.43 /usr/local/sbin/httpd
 9240  ??  I      1:23.04 /usr/local/sbin/httpd
 9295  ??  I      1:43.14 /usr/local/sbin/httpd
 9310  ??  I      0:31.92 /usr/local/sbin/httpd
 9349  ??  I      1:30.91 /usr/local/sbin/httpd
 9400  ??  I      1:33.04 /usr/local/sbin/httpd
 9520  ??  I      2:54.29 /usr/local/sbin/httpd
 9684  ??  I     24:10.87 /usr/local/sbin/httpd
11194  ??  I      1:00.40 /usr/local/sbin/httpd
11195  ??  I     10:04.76 /usr/local/sbin/httpd
11235  ??  I     14:39.19 /usr/local/sbin/httpd
11450  ??  I      0:46.55 /usr/local/sbin/httpd
11454  ??  I      0:54.18 /usr/local/sbin/httpd
11536  ??  I      0:57.52 /usr/local/sbin/httpd
11537  ??  I      0:57.79 /usr/local/sbin/httpd
11553  ??  I      1:04.38 /usr/local/sbin/httpd
11879  ??  I      1:47.63 /usr/local/sbin/httpd
11983  ??  I      4:41.52 /usr/local/sbin/httpd
12183  ??  S     19:23.89 /usr/local/sbin/httpd
12245  ??  I      4:14.40 /usr/local/sbin/httpd
12287  ??  I      7:44.76 /usr/local/sbin/httpd
12323  ??  I     13:32.37 /usr/local/sbin/httpd
12395  ??  I      0:49.69 /usr/local/sbin/httpd
12426  ??  I      6:46.30 /usr/local/sbin/httpd
12883  ??  I      0:31.24 /usr/local/sbin/httpd
12919  ??  I      4:19.26 /usr/local/sbin/httpd
12927  ??  I      2:03.11 /usr/local/sbin/httpd
12985  ??  I      0:59.90 /usr/local/sbin/httpd
13184  ??  I      2:11.55 /usr/local/sbin/httpd
13364  ??  S      2:25.69 /usr/local/sbin/httpd
13431  ??  Ss     0:00.42 sshd: jmkg@ttyp0 (sshd)
13484  ??  S      0:20.71 /usr/local/sbin/httpd
13485  ??  S      0:17.73 /usr/local/sbin/httpd
13487  ??  S      0:20.49 /usr/local/sbin/httpd
13488  ??  S      0:14.93 /usr/local/sbin/httpd
13491  ??  S      0:16.97 /usr/local/sbin/httpd
13492  ??  S      0:06.63 /usr/local/sbin/httpd
13499  ??  S      0:10.34 /usr/local/sbin/httpd
13502  ??  S      0:10.06 /usr/local/sbin/httpd
13522  ??  S      0:00.09 /usr/local/sbin/httpd
13523  ??  S      0:00.01 /usr/local/sbin/httpd
13524  ??  S      0:00.01 /usr/local/sbin/httpd
13525  ??  S      0:00.16 /usr/local/sbin/httpd
13526  ??  S      0:00.01 /usr/local/sbin/httpd
13527  ??  S      0:00.14 /usr/local/sbin/httpd
13528  ??  S      0:00.09 /usr/local/sbin/httpd
13529  ??  S      0:00.11 /usr/local/sbin/httpd
13533  ??  S      0:00.08 /usr/local/sbin/httpd
13534  ??  S      0:00.01 /usr/local/sbin/httpd
13535  ??  S      0:00.00 /usr/local/sbin/httpd
13536  ??  S      0:00.01 /usr/local/sbin/httpd
13537  ??  S      0:00.00 /usr/local/sbin/httpd
13538  ??  S      0:00.00 /usr/local/sbin/httpd
13540  ??  S      0:00.00 /usr/local/sbin/httpd
13543  ??  S      0:00.00 /usr/local/sbin/httpd

This was after a graceful restart. Other sites on the same server doing light traffic. I've had to install a maintenance page on the site (a small html file) to prevent php kicking in and hanging mysqld and httpd. Bear with me whilst I attempt to get useful info.
 [2002-07-26 05:25 UTC] james at stealthnet dot co dot uk
With the site hung:
 9:19AM  up 2 days, 11:55, 1 user, load averages: 2.08, 1.99, 1.70
With the site showing a plain html page for maintenance:
 9:24AM  up 2 days, 12 hrs, 1 user, load averages: 0.01, 0.69, 1.17
 [2002-07-26 05:36 UTC] james at stealthnet dot co dot uk
And now the script, that is separate to the main site that hangs, doesn't want to segfault and instead works perfectly... For now.

To see hang, visit and hope it's not working at the time. Apache loads mod_php4 as php was compiled --with-apxs=/path/to/apxs.

These are some of the log messages we're getting whilst it's down: - - [26/Jul/2002:00:04:25 +0000] "GET / HTTP/1.1" 200 5 "-" "Mozill
a/4.0 (compatible; MSIE 6.0; Windows 98)" - - [26/Jul/2002:00:04:37 +0000] "GET / HTTP/1.1" 200 5 "-" "Mozil
la/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)" - - [26/Jul/2002:00:05:21 +0000] "GET / HTTP/1.1" 200 5 "-" "Mozil
la/4.0 (compatible; MSIE 6.0; Windows 98)" - - [26/Jul/2002:00:05:59 +0000] "GET / HTTP/1.1" 200 5 "-" "Mozilla/
4.0 (compatible; MSIE 5.5; Windows NT 5.0)" - - [26/Jul/2002:00:06:59 +0000] "GET / HTTP/1.1" 200 5 "-" "Moz
illa/4.0 (compatible; MSIE 6.0; Windows 98)"

The / homepage redirects to a more suitable page (home.php) once a country selection has been made:

r2b% grep -c home.php f4p-access.log

Hardly anyone has managed to get there.
 [2002-07-26 05:39 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

 [2002-07-26 05:40 UTC] james at stealthnet dot co dot uk
Got it to crash this time:

r2b% sudo php -f xml-database.php > db.xml
php in free(): warning: recursive call
php in free(): warning: recursive call
php in free(): warning: recursive call
php in free(): warning: recursive call
php in free(): warning: recursive call
php in free(): warning: recursive call
php in free(): warning: recursive call
zsh: segmentation fault (core dumped)  sudo php -f xml-database.php > db.xml

I'm talking to people in charge to get a snapshot copy of the script and database posted for you. FWIW I'm not using free() in my script.
 [2002-07-26 06:10 UTC] killswitch at hackermail dot com
I have a similar problem. After a system crash I couldn?t access my website anymore. I used lynx to connect to my site and it hangs displaying this message: ?HTTP request sent; waiting for response?. I tried to access to a subdirectory and my PHP pages are displayed correctly. (All pages are accessing the same mysql database). I tried an other subdirectory and the browser hangs again. This was Linux Suse 7.2 (2.4.4) with preinstalled Apache and mod_php4.0.6. I thought I could solve the problem by updating apache to 1.3.26 and PHP to 4.2.2. The problem is still the same. 
Apache doesn?t recognize any connect attempts, because no log file (error.log, access.log) contains any information about my connect attempts to non-working PHP pages. 
I created a PHP file containing ?<? phpinfo() ?>? and put it into the non working web root directory. This file is displayed correctly. I tried the same with a more complex PHP file not accessing a mysql database. It worked. How is it possible that all PHP files of a whole directory accessing mysql databases are working and the same! files (copy, paste) in the next directory aren?t?

see it in action:  //isn't working    //is working
 [2002-07-26 07:20 UTC] james at stealthnet dot co dot uk
GDB says:

Reading symbols from /usr/libexec/
#0  0x80d63d4 in _efree (ptr=0x829e024,
    __zend_filename=0x812ff7c "zend_execute_API.c", __zend_lineno=274,
    __zend_orig_filename=0x8130813 "zend_variables.c", __zend_orig_lineno=44)
    at zend_alloc.c:240
240             REMOVE_POINTER_FROM_LIST(p);
(gdb) bt
#0  0x80d63d4 in _efree (ptr=0x829e024,
    __zend_filename=0x812ff7c "zend_execute_API.c", __zend_lineno=274,
    __zend_orig_filename=0x8130813 "zend_variables.c", __zend_orig_lineno=44)
    at zend_alloc.c:240
#1  0x80e60d0 in _zval_dtor (zvalue=0x819a5e4,
    __zend_filename=0x812ff7c "zend_execute_API.c", __zend_lineno=274)
    at zend_variables.c:44
#2  0x80ddb77 in _zval_ptr_dtor (zval_ptr=0x818a430,
    __zend_filename=0x8130813 "zend_variables.c", __zend_lineno=189)
    at zend_execute_API.c:274
#3  0x80e6488 in _zval_ptr_dtor_wrapper (zval_ptr=0x818a430)
    at zend_variables.c:189
#4  0x80ecb8a in zend_hash_destroy (ht=0x8158de8) at zend_hash.c:541
#5  0x80dd876 in shutdown_executor () at zend_execute_API.c:173
#6  0x80e72c4 in zend_deactivate () at zend.c:596
#7  0x805cc72 in php_request_shutdown (dummy=0x0) at main.c:787
#8  0x805b582 in main (argc=3, argv=0xbfbffbd8) at cgi_main.c:827
#9  0x805a565 in _start ()

Note no execute() function which seems to tie in with my not always finding connection attempts logged in the f4p.log access log (well, clutching at straws).
 [2002-07-26 07:26 UTC]
If possible, please try this snapshot:

(can't get any worse, can it? :)

 [2002-07-26 07:46 UTC] james at stealthnet dot co dot uk
Installed the CGI edition of that snapshot and so far on that one script it's worked 2/2 times. Not to say the old version didn't, but it'll take some testing before I'm confident that the problem is fixed in this snapshot.

I'll load it up on my dev box and see what breaks. Stay tuned.
 [2002-08-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 04:01:29 2023 UTC