php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20871 Apache restarts with no output
Submitted: 2002-12-06 19:42 UTC Modified: 2003-02-07 23:50 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ctocopok at fond-darina dot ru Assigned:
Status: No Feedback Package: IMAP related
PHP Version: 4.3.0-dev OS: win2K
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: ctocopok at fond-darina dot ru
New email:
PHP Version: OS:

 

 [2002-12-06 19:42 UTC] ctocopok at fond-darina dot ru
Trying to make a mailling list script on a php encountered a strange PHP behaviour.

config: Win2K, Apache 1.3.20 (Win32), PHP 4.2.3 (just downloaded from php.net)

Script: 
<? 
//diff set-up steps skipped
$mbox = imap_open ("{".$server.":".$port."/pop3}INBOX", "$uname", "$passw");

//following lines work on the results
?>

first I worked with my local pop3 server (WinRoute built-in). everything went fine, but then suddenly I got no changes in the output after I was changing my script.

I changed the server to another one (mail.ru) and continued working. 30 minutes of happy working until that server went "dead" too. 

I changed the pop3 server the third time. It worked, but finally began bugging too!

I started searching the point where the bug comes from. 
got the following from apache error.log file (debug level of logging):
--------
abnormal program termination
[Sat Dec 07 04:34:06 2002] [info] master_main: Child processed exited (due to MaxRequestsPerChild?). Restarting the child process.
[Sat Dec 07 04:34:06 2002] [info] Parent: Created child process 2100
[Sat Dec 07 04:34:06 2002] [info] Parent: Duplicating socket 428 and sending it to child process 2100
[Sat Dec 07 04:34:07 2002] [info] BytesRead = 372 WSAProtocolInfo = 2006620
--------

Phperror.log contains nothing about the problem. 

Commenting the "$mbox = imap_open()" makes script working as usual. 

starting the script with "php -f script.php >1.html" make PHP print "abnormal program termination" and quit. 
1.html file remains empty.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-06 20:01 UTC] ctocopok at fond-darina dot ru
Same thing happens on a machine that is described by phpinfo() like following:
------------------------------------------------------
System FreeBSD v6.valuehost.ru 4.4-STABLE FreeBSD 4.4-STABLE #0: Mon Jan 14 05:22:29 MSK 2002 egor@v6.valuehost.ru:/usr/src/sys/compile/V6 i386 
Build Date Sep 19 2002 15:39:18 
Configure Command './configure' '--prefix=/usr/local' '--with-config-file-path=/usr/local/etc' '--enable-memory-limit' '--with-gd=/usr/local' '--with-freetype-dir=/usr/local' '--enable-gd-native-ttf' '--with-zlib' '--with-pdflib=/usr/local' '--with-zlib-dir=/usr' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-tiff-dir=/usr/local' '--with-mysql=/usr/local/mysql' '--with-dbase' '--with-ldap=/usr/local' '--with-openssl=/usr/local' '--with-xml' '--enable-xslt' '--with-dom=/usr/local' '--with-xslt-sablot' '--with-expat-dir=/usr/local' '--with-t1lib=/usr/local' '--with-curl=/usr/local' '--with-gettext=/usr/local' '--with-iconv=/usr/local' '--with-mcrypt=/usr/local' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--enable-sockets' '--with-imap=/usr/local' '--enable-ftp' '--enable-exif' '--enable-mbstring' '--enable-mbregexp' '--enable-bcmath' 
Server API Apache
 [2002-12-06 20:05 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip
 [2002-12-06 20:10 UTC] ctocopok at fond-darina dot ru
test script could be reached at http://decmon.fond-darina.ru/mail.php and http://decmon.fond-darina.ru/mail.php?phpinfo=1

the latter one will start producing phpinfo() report (I added "if (isset($phpinfo))phpinfo();" line to the beginning of the script
 [2002-12-06 20:25 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-12-06 20:38 UTC] ctocopok at fond-darina dot ru
Latest snapshot did not help. Actually, i fount the better place to "breakpoint" - I did comment out the line containing "$headers=imap_search($mbox, "FROM @");"

*perhaps* that is the point where a crash(?) occures.
 [2002-12-11 04:22 UTC] ctocopok at fond-darina dot ru
I'd be glad to know if any measures are being taken in order to fix the buggie. 
I hope that you at least succeeded reproduction of the bug.
 [2002-12-11 05:14 UTC] sniper@php.net
Please provide a short, complete and self-contained example
script which can be used to reproduce this.

 [2002-12-11 05:48 UTC] ctocopok at fond-darina dot ru
<?
$port="110";
$server="localhost";
$uname="test";
$passw="1234";

phpinfo(); //to start the output

$mbox = imap_open ("{".$server.":".$port."/pop3}INBOX", "$uname", "$passw");
echo imap_last_error()."<br>";

$totmsg=imap_num_msg($mbox); //still works
if ($totmsg>0) echo "some messages found<br>";

$headers=imap_search($mbox, "FROM @", 0);//fails
$headers=imap_headers($mbox);//fails

//any of above would 'crash'.


if (is_array($headers))echo "Total messages found: ".count($headers)."/$totmsg<br>";
?>
 [2002-12-19 16:37 UTC] ctocopok at fond-darina dot ru
Sorry for bothering. Any good news on the subject?
 [2002-12-23 09:03 UTC] ctocopok at fond-darina dot ru
imap_fetchbody() fails. 

I had to add some code to the script to make it write all it's output to some file on disk (i simply cloned "echo" with "fputs").

Now it seems that the imap_fetchbody() function makes apache restart (and PHP - to crash). Sorry for previous mishinting.
 [2003-01-18 01:11 UTC] sniper@php.net
Does the crash happen with any email you're trying to get?
And please add short example script here too and information
about the imap/pop3 server you're connecting to.
(Version, etc.)


 [2003-01-26 12:34 UTC] ctocopok at fond-darina dot ru
Yes. The crash happens with any e-mail. Does not depend on the e-mail encoding or charset or whatever. It happens, I suppose, in imap_fetchbody, the function I use to get the raw e-mail headers (the used to fall into section #0 of the e-mail body, no matter if mail had any parts). 
As to the script - the PHP-file I use to test the bug is constantly growing as I add more debug output to find the exact point where the 'crash' occurs.

As to the servers - there are many if them. WinRoute's internal pop3 server (my local), and some other servers on the net (mail.ru, goals.ru, valuehost.ru) - these are the servers I tried. 

Local testing reports that the mails get transferred to PHP. Even twice (so if the mailbox occupies 100Kbytes of mail for user, the total session traffic would be 200K).

Here is the script I use now (still crashiong with fetchbody):

<?
ini_set("display_startup_errors","1");
$f=fopen('log','w+');

$enc[0]="7BIT";
$enc[]="8BIT";
$enc[]="BINARY";
$enc[]="BASE64";
$enc[]="QUOTED-PRINTABLE";
$enc[]="OTHER";

$port="110";

$server="localhost";
$uname="test";
$passw="1234";

//phpinfo();

 function desc_arr($arr,$prefix)
 { 
 global $f;

  foreach($arr as $key=>$value)
   { 
    echo "$prefix [$key] = $value <br>";
    fputs($f, "$prefix [$key] = $value <br>\n");


    if (is_array($value))desc_arr($value, "$prefix [$key]");
    if (is_object($value))desc_obj($value,"$prefix [$key]");
   }
  }

function desc_obj($obj, $prefix)
 { 
  global $f;
  foreach($obj as $key=>$value)
   { 
    echo "$prefix -> $key = $value <br>";
    fputs($f, "$prefix -> $key = $value <br>\n");

    if (is_array($value))desc_arr($value, "$prefix -> $key");
    if (is_object($value))desc_obj($value,"$prefix -> $key");
   }
  }
   

fputs($f, "connecting to $server<br>\n");
echo "connecting to $server<br>";

$mbox = imap_open ("{".$server.":".$port."/pop3}INBOX", "$uname", "$passw");



echo imap_last_error()."<br>";
fputs($f,imap_last_error()."<br>\n");

echo "Retrieving messages...<br>";
fputs($f, "Retrieving messages...<br>");

$totmsg=imap_num_msg($mbox);

 $check = imap_mailboxmsginfo($mbox);
 
if($check) {
    print "Date: "    . $check->Date    ."<br>\n" ;
    fputs($f, "Date: "    . $check->Date    ."<br>\n" );
    print "Driver: "  . $check->Driver  ."<br>\n" ;
    print "Mailbox: " . $check->Mailbox ."<br>\n" ;
    print "Messages: ". $check->Nmsgs   ."<br>\n" ;
    print "Recent: "  . $check->Recent  ."<br>\n" ;
    print "Unread: "  . $check->Unread  ."<br>\n" ;
    print "Deleted: " . $check->Deleted ."<br>\n" ;
    print "Size: "    . $check->Size    ."<br>\n" ;
} else {
    print "imap_check() failed: ".imap_last_error(). "<br>\n";
    fputs($f,"imap_check() failed: ".imap_last_error(). "<br>\n");
}


if ($totmsg>0) {echo "some messages found<br>";fputs($f,"some messages found<br>\n");}
if ($totmsg>0) echo "some messages found<br>";
if ($totmsg>0) echo "some messages found line 3<br>";
$headers=imap_search($mbox, "FROM @", 0);//


if (is_array($headers))
 {echo "Total messages found: ".count($headers)."/$totmsg<br>";
  fputs($f,"Total messages found: ".count($headers)."/$totmsg<br>\n");
  desc_arr($headers, "headers");

  }

    while (list ($key,$val) = each ($headers)) {
     
        
        unset($hdr);
        $hdr=imap_headerinfo($mbox, ($val));
        desc_obj($hdr, "HDR:");
        
        echo "Plaintext is:<br><code>".nl2br(imap_body($mbox, ($val)))."</code><br>";
        fputs($f,"Plaintext is:<br><code>".nl2br(imap_body($mbox, ($val)))."</code><br>\n");
        
        
        
        echo "<hr>...Fetching structure<br>";
        fputs($f,"<hr>...Fetching structure<br>\n");


        unset($struc);
        $struc=imap_fetchstructure($mbox,($val));

        echo "struc assigned<br>";
        fputs($f, "struc assigned\n");

        desc_obj($struc, "structure");
   

   if (isset($struc->parts))	//There are some parts
    { 
     echo "<b>there are ".count($struc->parts)." parts in the message</b><br>";
     fputs($f, "<b>there are ".count($struc->parts)." parts in the message</b><br>\n");


      foreach($struc->parts as $num=>$part)
       { 
        echo "foreach struc-parts started<br>";
        fputs($f, "foreach struc-parts started<br>\n");

        echo "Part $num<br>";
        fputs ($f, "Part $num<br>\n");

        if ($part->subtype=='PLAIN')
        {
          echo "part subtype=PLAIN<br>";
          fputs($f, "part subtype=PLAIN<br>\n");

         $msg=imap_fetchbody($mbox,$key, $num); // ***CRASH *** //



         echo "The text is ".nl2br($msg)." <br>";
         fputs($f,"The text is ".nl2br($msg)." <br>\n");
        }
        $filename="";
        if ($part->ifdisposition==1)
         {
          echo "Part $num has disposition $part->disposition<br>";
          fputs($f, "Part $num has disposition $part->disposition<br>\n");

          if ($part->ifdparameters==1)
           {
            echo "there are Dparameters for it<br>";
            fputs($f, "there are Dparameters for it<br>\n");

            foreach ($part->dparameters as $dpname=>$dpval)
             {
              if ($dpval->attribute=="FILENAME"){
              echo "Filename is ".($filename=$dpval->value)."<br>";
              fputs($f, "Filename is ".($filename=$dpval->value)."<br>\n");
              }
             }
           }
         }

       }
   
    }
    else
    {
     echo "<b>Seems this message has the only part</b>:<br><code>".imap_body($mbox, ($val))."</code><br>";
     fputs($f, "<b>Seems this message has the only part</b>:<br><code>".imap_body($mbox, ($val))."</code><br>\n");
    }

    echo "<hr>Body:<br>".imap_body($mbox, ($val))."<br><hr>";
    fputs($f, "<hr>Body:<br>".imap_body($mbox, ($val))."<br><hr>\n");

    echo "Part0 if exists:<br>";
    fputs($f, "Part0 if exists:<br>\n");
    echo "Key: $key, val: $val<br>";
    $alerts=imap_alerts();
    if(is_array($alerts))echo "Here we have alerts:<br>".desc_arr($alerts," ALRT:");
    echo "Alerts:".$alerts;

    echo "lalala".imap_fetchheader($mbox,$key+1);
//    fputs($f, "\nlalala".imap_fetchbody($mbox,$key, 0)); //commented out because of crash
 }

imap_close($mbox);

?>
 [2003-02-07 23:50 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC