On October 12, 2002 07:38 am, Wez Furlong wrote: > On 10/12/02, "Ilia A." <[EMAIL PROTECTED]> wrote: > > So, I think this is indeed a problem. Allocating a huge buffer just > > because users says so is not right, we might as well allow people direct > > memory access while we are at it. One thing is that if this were to fail > > because there were really 1000000000 bytes to read and PHP could not > > allocate that much memory to store all this data. Even then, a graceful > > exit would've been nicer then a segmentation fault, but that's already > > arguable. > > Lets have a backtrace please.
#0 0x403cd271 in ?? () #1 0x8171922 in zif_fgets (ht=2, return_value=0x83c843c, this_ptr=0x0, return_value_used=0) at /home/rei/PHP_CVS/php4/ext/standard/file.c:1271 #2 0x823faa2 in execute (op_array=0x83d498c) at /home/rei/PHP_CVS/php4/Zend/zend_execute.c:1597 #3 0x822c9e4 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/rei/PHP_CVS/php4/Zend/zend.c:839 #4 0x81f2d81 in php_execute_script (primary_file=0xbffff6b0) at /home/rei/PHP_CVS/php4/main/main.c:1542 #5 0x8250b47 in main (argc=2, argv=0xbffff734) at /home/rei/PHP_CVS/php4/sapi/cli/php_cli.c:695 #6 0x403bdf5c in ?? () The core is actually intentionally done by emalloc(), which terminates execution when it cannot allocate requested memory. That is correct behaviour, what is not correct is that fread() tries to blindly allocate that much data without actually seeing how much data there is on a socket. I realize that doing one emalloc() is faster then doing many ereallocs() to increase the buffer when its size is reached. However, the latter IMHO is the correct behaviour not to mention that it works correctly in PHP 4.2.3 and lower. > > One more issue that I've come across since the last email is the > > following leak in the streams code. > > /home/rei/PHP_CVS/php4/main/streams.c(986) : Freeing 0x084DA69C (1 > > bytes), script=/home/rei/PHP_CVS/php4/run-tests.php > > /home/rei/PHP_CVS/php4/ext/standard/file.c(438) : Actual location > > (location was relayed) > > > > Unfortunately, I am unable to reproduce the with a small test scripts, so > > not much detail about this leak atm, I'm afraid. > > If you could update your CVS as well, so that the line numbers match > the repository, that would help too :-) It appears that the latest CVS is free of this bug, I guess your patch fixed it :). The other bug with sending binary data via a socket also appears to have been fixed by your patch. Ilia -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php