php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43023 Bug on set stream NULL
Submitted: 2007-10-18 18:04 UTC Modified: 2007-10-29 01:00 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: federeghe at hotmail dot it Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5.3CVS-2007-10-18 (CVS) OS: All
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-10-18 18:04 UTC] federeghe at hotmail dot it
Description:
------------
View code. On 4? line, apache crashes...

Reproduce code:
---------------
$this->stream = fopen('./html/page.phtml', 'r');
$this->page = fread($this->stream,filesize('./html/page.phtml'));
fclose($this->stream);
$this->stream=NULL;  //Crash apache (???)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-19 08:31 UTC] johannes@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.
 [2007-10-19 08:32 UTC] johannes@php.net
And please explain what "crash" means in this context. A segfault? Then please also provide a backtrace.
 [2007-10-19 12:50 UTC] federeghe at hotmail dot it
This is complete script
<?php

if(!defined("IN_RESCHOOL")) exit; 							//If not defined "go costant" exit
error_reporting("E_ALL");
$file = new file;
$page = new page;

function inc($file,$once=0) {
	if($once==0) {
		include($file);
	}
	if($once==1) {
		include_once($file);
	}
}

class file
{
 	var $stream;
	function read($filename)
	{
		$this->stream = fopen('./'.$filename, 'r');
		$return = fread($this->stream,filesize($filename));
		fclose($this->stream);
		$this->stream=NULL;  //Crash apache (???)
		return($return);
	}
}

class page 
{
	var $content;
	var $head;
	var $title;
	
	function add($text) 
	{
		$this->content.=$text;
	}
	
	function head($text)
	{
		$this->head=$text;
	}
	function title($title)
	{
		$this->title=$title;	
	}
	
	function go()
	{
	 	global $file;
		$html = $file->read('html/standard.phtml');
		$html = replace($html);
		echo $html;
	}
	
	function replace($text) 
	{
		$text = str_replace("{CONTENT}",$this->content,$text);
		$text = str_replace("{TITLE}",$this->title,$text);
		$text = str_replace("{HEAD}",$this->head,$text);
		$text = str_replace("{MENU}",$this->menu(),$text);
		$text = str_replace("{NAME}",$config->name_school,$text);
		return($text);
	}

	function specialpage($page)
	{
	 	global $file;
		switch($page) 
		{
			case('login-student'):
				$this->title = 'Login';
				$this->head($file->read('html/login-student-head.phtml'));
				$this->add($file->read('html/login-student.phtml'));
			break;
			case('login-prof'):
				$this->title = 'Login Prof';
				$this->head($file->read('html/login-prof-head.phtml'));
				$this->add($file->read('html/login-prof.phtml'));
			break;
		}
	}

}

?>

In windows the crash is:

"Si ? verificato un errore in Apache.exe. L'applicazione verr? chiusa."
equal to
"An error occurred in Apache.exe. The application will be closed."

on linux I don't know the crash but 
"The page cannot be displayed"
to all other pages.
 [2007-10-19 12:52 UTC] federeghe at hotmail dot it
on 3? line there isn't "exit"... Error on copy-past
 [2007-10-21 15:27 UTC] iliaa@php.net
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
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

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.


 [2007-10-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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-2022 The PHP Group
All rights reserved.
Last updated: Wed Jul 06 02:03:41 2022 UTC