php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25072 include and user_space stream
Submitted: 2003-08-13 05:26 UTC Modified: 2003-08-18 19:45 UTC
From: eduard at sitesupra dot com Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 4.3.3RC4-dev OS: WinXP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-08-13 05:26 UTC] eduard at sitesupra dot com
Description:
------------
On windows:

When you have include() from userstream
result of stream_eof() is ignored and stream_read() called 2 times more

When few requests occur simultaneosly - apache crushes.

On Linux - this works correctly

Reproduce code:
---------------
<?php
class userstream
{
	var $position = 0;
	var $data = "If you can read this, it worked";
	function stream_open($path, $mode, $options, &$opened_path)
	{
		return true;
	}
	function stream_read($count)
	{
		$ret = substr($this->data, $this->position, $count);
		$this->position += strlen($ret);
		echo "READ {$this->position}\n";
		return $ret;
	}
	function stream_eof()
	{
		echo "EOF\n";
		return $this->position >= strlen($this->data);
	}
	function stream_seek($offset,$whence)
	{
		echo "SEEK\n";
	}
	function stream_tell()
	{
		echo "TELL\n";
		return $this->position;
	}
	function stream_stat()
	{
		echo "STAT\n";
		return NULL;
	}
	function stream_close()
	{
		echo "CLOSE\n";
	}
}
stream_register_wrapper("cookietest", "userstream");
include("cookietest://foo");
?>


Expected result:
----------------
SEEK
TELL
READ 31
EOF
CLOSE
If you can read this, it worked


Actual result:
--------------
SEEK
TELL
STAT
READ 31
EOF
READ 31
EOF
READ 31
EOF
CLOSE
If you can read this, it worked


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-13 05:49 UTC] eduard at sitesupra dot com
on 4.3.3RC4-dev same result as 4.3.2
 [2003-08-13 13:26 UTC] pollita@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

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.

On the first point, the extra reads are include() being cautious.  It doesn't EXPECT any data, but on the off chance the EOF status changed (socket streams are allowed to do that) it double checks.

As to the crash though, that definately shouldn't be happening.  Could you provide a backtrace using the instructions above?  It'll help track the problem down.

 [2003-08-13 13:52 UTC] pollita@php.net
As another developer just reminded me, generating backtraces on windows isn't an option.

You mention having access to a linux machine, can you recompile your PHP on that box using the configure option "--enable-experimental-zts" (this will make it behave like its Win32 counterpart) and see if its possible to recreate the crash there.  If so generate a backtrace from that please.

 [2003-08-18 19:45 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-2021 The PHP Group
All rights reserved.
Last updated: Fri Mar 05 20:01:24 2021 UTC