php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14599 Script Output Stops
Submitted: 2001-12-19 07:21 UTC Modified: 2002-01-09 02:10 UTC
From: darren at coolpink dot net Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.1.0 OS: SuSE Linux 6.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: darren at coolpink dot net
New email:
PHP Version: OS:

 

 [2001-12-19 07:21 UTC] darren at coolpink dot net
PHP script stops 3/4 of the way down a medium sized page. This happens in exactly the same place.

Apache log shows:

[Wed Dec 19 11:24:55 2001] [notice] child pid 13078 exit signal Segmentation fault (11)
[Wed Dec 19 11:26:55 2001] [notice] child pid 12877 exit signal Segmentation fault (11)
[Wed Dec 19 11:27:51 2001] [notice] child pid 13465 exit signal Segmentation fault (11)
[Wed Dec 19 11:28:45 2001] [notice] child pid 13468 exit signal Segmentation fault (11)
[Wed Dec 19 11:30:54 2001] [notice] child pid 13469 exit signal Segmentation fault (11)
[Wed Dec 19 11:34:17 2001] [notice] child pid 13566 exit signal Segmentation fault (11)
[Wed Dec 19 11:34:37 2001] [notice] child pid 13580 exit signal Segmentation fault (11)
[Wed Dec 19 11:34:39 2001] [notice] child pid 13581 exit signal Segmentation fault (11)
[Wed Dec 19 11:34:48 2001] [notice] child pid 13582 exit signal Segmentation fault (11)
[Wed Dec 19 11:39:15 2001] [notice] caught SIGTERM, shutting down
[Wed Dec 19 11:43:15 2001] [notice] Apache/1.3.12 (Unix)  (SuSE/Linux) mod_fastcgi/2.2.2 mod_perl/1.21 PHP/4.1.0 configured -- res
uming normal operations
[Wed Dec 19 11:43:15 2001] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
ild pid 13078 exit signal Segmentation fault (11)[Wed Dec 19 12:05:32 2001] [notice] child pid 163 exit signal Segmentation fault

The PHP page is meant to output a html form containing hidden form fields.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-19 07:30 UTC] lobbin@php.net
Please provide a small script which can be used to produce this error, and also, if you can, provide a backtrace.

http://bugs.php.net/bugs-generating-backtrace.php


R.
 [2002-01-09 02:10 UTC] lobbin@php.net
No feedback. Closing.
 [2002-10-31 03:39 UTC] john at alamak dot com dot sg
I get this all the time when I include a recursive function call. I've tried rewriting the function several ways and get intermitten Segmentation faults.

I"ve tried just opening the fh and going down recursive directories with this, got the seg faults often.This version
buffers the file names in an array, closes the directory handle then processes the array, to count certain types of files in the directory tree. Still segfaults often enough to make it unreliable. I turned on the autoflush in php.ini and it dies in this routine.

FreeBSD 4.5-RELEASE
Apache/1.3.26 (Unix) PHP/4.2.2 mod_ssl/2.8.9 OpenSSL/0.9.6g
RegisterGlobals = On  :)

function CountFiles($dir,$d) {
  global $home;
  global $prod_count;
  $farray = array(); $d++;
  if (is_dir("$home$dir")) {
    print "<!-- ISDIR dir=$dir level=$d -->\n";
    if ($dfh = @opendir("$home$dir")) {
	while (($fil = readdir($dfh)) !== false) {
		if (!preg_match("/^\.+$/", $fil)) {
			array_push($farray,"$fil");
		}
	}
	closedir($dfh);
	if (count($farray) > 0) {
	  while (list ($key, $file) = each ($farray)) {	
	    if (is_dir("$home$dir/$file")) {
		CountFiles("$dir/$file",$d);
		flush();
	    } else if (preg_match("/^thumb_\w+\.|\.wav$|\.aif$/", $file)) {				$prod_count++;
		print "<!-- POST dir=$dir/$file prod_count=$prod_count -->\n";
		flush();
	    }
	}
      }
    }
  }
  flush();
}

It's not entirely reproducible, but once I got a directory where it causes the segfault I can comment out this routine and it's okay, comment it back and reload and it segfaults.
So in that sense it's reproducible. Restarting the web server has no effect. Though if I reload enough times sometimes the script completes, there is definitely some sort of bug, maybe the filehandle or array declaration isn't local or leaks out, not sure.
 [2004-02-24 11:10 UTC] josh dot nospam at hostyour dot info dot nospam
I've noticed the same problem, and reproduced it in my own.  I have PHP 4.3.4 and Zend Optimizer 2.5.0 installed on RH7.3

If I have a function that has a do..while(); construction in it, inside a block container { }, PHP will segfault on exiting the block container UNLESS I have a statement in between the end of the while (); and the closing brace of the block.

This snippet segfaults:

function announce()
{
	global $totalRows_announce, $row_announce, $announce, $srs;

	$ann = "";

	if ($totalRows_announce > 0) {
		do {
			$author = mysql_result(mysql_query("SELECT nick FROM players WHERE id='".$row_announce['author']."'", $srs), 0, "nick") or die(mysql_error());
			$msg_body = stripslashes(implode("<br>",explode("\n",$row_announce['msg_body'])));
			$ann .= textBlock(textBlock($row_announce['subject'], "", "anntitle") . br() . 
				textBlock("Posted by:".$author." | On: ".$row_announce['posted_date'], "", "annhead") . br() .
				textBlock($msg_body, "", "annbody"), "", (($row_announce['urgent'] == 1) ? "redrow" : ((($ctr++) % 2) ? "lightrow" : "darkrow"))) . br();
		} while ($row_announce = mysql_fetch_assoc($announce));
	} else {
		$ann = textBlock("No Announcements", "", "loginerr");
	} 
	return $ann;
}

This one does not:

function announce()
{
	global $totalRows_announce, $row_announce, $announce, $srs;

	$ann = "";

	if ($totalRows_announce > 0) {
		do {
			$author = mysql_result(mysql_query("SELECT nick FROM players WHERE id='".$row_announce['author']."'", $srs), 0, "nick") or die(mysql_error());
			$msg_body = stripslashes(implode("<br>",explode("\n",$row_announce['msg_body'])));
			$ann .= textBlock(textBlock($row_announce['subject'], "", "anntitle") . br() . 
				textBlock("Posted by:".$author." | On: ".$row_announce['posted_date'], "", "annhead") . br() .
				textBlock($msg_body, "", "annbody"), "", (($row_announce['urgent'] == 1) ? "redrow" : ((($ctr++) % 2) ? "lightrow" : "darkrow"))) . br();
		} while ($row_announce = mysql_fetch_assoc($announce));
		echo "";
	} else {
		$ann = textBlock("No Announcements", "", "loginerr");
	} 
	return $ann;
}

Note that the only difference between the two is the echo ""; statement immediately following the while(); clause.

This does NOT happen in "global" execution.  A do..while() loop that lives outside any function's scope works just fine; I have several other do..while() constructs outside of functions that work with no problems.  The segfault seems to only happen when the do..while(); is inside a function AND inside a block container (in this case, belonging to an if statement).

Any ideas?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 19:01:29 2024 UTC