php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41932 fsockopen - apache2 poblem with many vhosts
Submitted: 2007-07-09 07:43 UTC Modified: 2007-07-10 08:03 UTC
From: yaboll at interia dot pl Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.4.7 OS: linux
Private report: No CVE-ID: None
 [2007-07-09 07:43 UTC] yaboll at interia dot pl
Description:
------------
I found problem in fsockopen() when I use php as module mod_php in apache2.

When I create many vhost fsckopen() doesn't work good and generate child sigterm error.

I made some experimets with vhost number:

vhosts number - error

less than 1005 - work fine
1006-1007 - white page (no error)
1008 - around 1164 - "Operation now in progress (115)"
around 1150 - around 1164 - "Bad file descriptor (9)"
around 1164 - around 1200 - "Operation now in progress (115)"
1200 and more - apache child sigterm



core in sigterm:
(gdb) bt
#0 php_hostconnect (host=Cannot access memory at address 0xc
) at /srv/dev-dev/php4-debug/php4/php4-4.4.7/main/network.c:490
Cannot access memory at address 0x4
(gdb)


When I use php in cgi/cli mode all works fine.

Reproduce code:
---------------
<?php
 $fp = fsockopen("www.onet.pl", 80, $errno, $errstr, 30);
 if (!$fp) {
  echo "$errstr ($errno)<br />\n";
 } else {
   $out = "GET / HTTP/1.1\r\n";
   $out .= "Host: www.onet.pl\r\n";
   $out .= "Connection: Close\r\n\r\n";
   fwrite($fp, $out);
   while (!feof($fp)) {
    echo fgets($fp, 128);
   }
   fclose($fp);
 }
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-09 08:10 UTC] yaboll at interia dot pl
Well, as this bug is version 4.4.7 related, I hope that this is some kind of automatic reply :D
Downloading 5.2 will solve the problem, but it would be nice to see it corrected in php4.
 [2007-07-09 20:32 UTC] tony2001@php.net
You've run into your system's file descriptor limit.
Not PHP problem.
 [2007-07-10 08:03 UTC] yaboll at interia dot pl
There is no nfile limit in apache server.
When i change nfile limit I have the same results (error or seqfault) 

Limit are set to unlimited/high value intentionally for this test:

This is results in 
system('ulimit -a');

core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1048576
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) 250000



I would like to emphasize that when I use php 5.2 everything works fine within the same limits/apache2 config.


The problem is connected with php 4.4.7 in mod_php.

When i use 4.4.7 in cgi, or php 5.2 in mod_php (same ulimit and apache2 config) or 5.2 in cgi mode script return good results.
 [2010-03-15 05:09 UTC] marcelo at tpn dot com dot br
See http://bugs.php.net/bug.php?id=39803
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 16:01:30 2024 UTC