ID: 11199
Updated by: sniper
Reported By: [EMAIL PROTECTED]
Old Summary: fopen wrapper is broken. fopen('http://www.php.net/','r') does not work.
Status: Analyzed
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.0 Latest CVS (2001-05-30)
New Comment:

updated summary


Previous Comments:
------------------------------------------------------------------------

[2001-06-01 00:02:59] [EMAIL PROTECTED]

You are absolutely right. This should cause something
else than mere 'exit(1)' by the Zend engine. 

(I do have memory_limit..it was set to 1500M :)

--Jani


------------------------------------------------------------------------

[2001-05-31 23:33:16] [EMAIL PROTECTED]

I think you don't have memory limit.

PHP allocates memory specified length for fread() and keep it. (This case is 10000001 
for every fread()) If it does not require that amount of memory, it would be nice to 
resize size of allocated memory since size of files are not known for remote files.

If this is designed behavior, I can live with that, though. But, it is better to be 
logged. I see no error log for this. (I use E_ALL and logs errors)

To make this clear, I changed status to open again.

Thanks for your time.

-- 
for($i = 0; $i <10; $i++) {
   $fp = fopen($HTTP_POST_VARS['file'],'r');
   $data = fread($fp, 10000000);
   fclose($fp);
}
--

#0  exit (status=1) at exit.c:40
#1  0x4051b38c in _emalloc (size=10000001) at zend_alloc.c:186
#2  0x405b4c94 in php_if_fread (ht=2, return_value=0x815ee6c, this_ptr=0x0, 
return_value_used=1) at file.c:2010
#3  0x4052cc84 in execute (op_array=0x816048c) at ./zend_execute.c:1504
#4  0x4053f5b1 in zend_execute_scripts (type=8, file_count=3) at zend.c:749
#5  0x40550f5b in php_execute_script (primary_file=0xbffff5c0) at main.c:1206
#6  0x4054d73a in apache_php_module_main (r=0x81533f8, display_source_mode=0) at 
sapi_apache.c:89
#7  0x4054e0d9 in send_php (r=0x81533f8, display_source_mode=0, filename=0x0) at 
mod_php4.c:539
#8  0x4054e112 in send_parsed_php (r=0x81533f8) at mod_php4.c:550
#9  0x8055957 in ap_invoke_handler ()
#10 0x8069c0b in process_request_internal ()
#11 0x8069c6c in ap_process_request ()
#12 0x8061041 in child_main ()
#13 0x8061210 in make_child ()
#14 0x8061384 in startup_children ()
#15 0x80619d3 in standalone_main ()
#16 0x806220b in main ()
#17 0x400b5b5c in __libc_start_main (main=0x8061e58 <main>, argc=2, ubp_av=0xbffff8c4, 
init=0x804fa50 <_init>, 
    fini=0x8099ffc <_fini>, rtld_fini=0x4000d634 <_dl_fini>, stack_end=0xbffff8bc)
    at ../sysdeps/generic/libc-start.c:129
(gdb) f 1
#1  0x4051b38c in _emalloc (size=10000001) at zend_alloc.c:186
186             CHECK_MEMORY_LIMIT(size, SIZE);


------------------------------------------------------------------------

[2001-05-31 12:30:23] [EMAIL PROTECTED]

This works for me just fine. There is something wrong
in your system / sources.  (I tried with PHP 4.0.6RC1)

--Jani


------------------------------------------------------------------------

[2001-05-31 01:05:12] [EMAIL PROTECTED]

The real problem was caused in different part of code.

Apahce exit with code 01 when there is following loop or
like. (file can be local or remote. Tested with 4.0.6RC1)

for($i = 0; $i <10; $i++) {
$fp = fopen($HTTP_POST_VARS['file'],'r');
$data = fread($fp, 10000000);
fclose($fp);
}

Opening the same file is only useful for benchmarks, though.

It seems there is no smilar open report for this.
I'll open new report for this, if you would like.

----------------------------------
<?php
if (isset($HTTP_POST_VARS['file']))
{
        for($i = 0; $i <10; $i++) {
                $fp = fopen($HTTP_POST_VARS['file'],'r');
                $data = fread($fp, 10000000);
                fclose($fp);
        }
}
?>
<html>
<head>
<title>fopen() test2</title>
</head>

<body>
<pre>
<form method="post">
<input type="text" name="file" value="<?php
@print($HTTP_POST_VARS['file']); ?>">
<input type="submit" name="submit" value="Execute fopen()">
</form>
<p>
<?php
if (isset($data))
{
        echo "\n==OUTPUT==\n";
        
        print(htmlspecialchars($data));

        echo "\n==END==\n";
        
}
else
{
        echo " No files are opened\n";
}

?>
</p>
</pre>
</body>
</html>
------------------------------------------

Looks like the loop triggers a bug.

PS: ezhttpdbench.php had useless line looks like
$filesize = filesize(<url's file descriptor>);
This line makes me confuse.


------------------------------------------------------------------------

[2001-05-30 22:17:00] [EMAIL PROTECTED]

Works for me just fine. Fix your system.

--Jani


------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/?id=11199


Edit this bug report at http://bugs.php.net/?id=11199&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to