Bug #14374 Updated: Reproductible crash (simple script) related to default variables/arrays
| From: | xroche at free dot fr | Date: | Fri, 07 Dec 2001 11:28:51 +0000 |
| Subject: | Bug #14374 Updated: Reproductible crash (simple script) related to default variables/arrays | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-72836@lists.php.net to get a copy of this message | ||
ID: 14374
User updated by: xroche@free.fr
Reported By: xroche@free.fr
Status: Closed
Bug Type: Arrays related
Operating System: Linux 2.2.20
PHP Version: 4.0.6
New Comment:
Seems to be fixed in CVS, sorry!
Previous Comments:
------------------------------------------------------------------------
[2001-12-07 06:15:34] derick@php.net
I can not reproduce this with php 4.1.0RC5 or php 4.2.0dev, so considered fixed.
(You can try yourself with www.php.net/~zeev/php-4.1.0RC5.tar.gz)
PHP 4.1.0 will be released in a few days now.
Derick
------------------------------------------------------------------------
[2001-12-07 06:09:05] xroche@free.fr
This following simple script will crash both PHP 4.06 (module and cgi) and previous 4.05 but NOT
4.03pl1 (?!), and might be related to the following bug ID's:
Bug id #12776
Bug id #14281
It seems that there's a problem between array variables, default values and empty arrays
accessed through index (a null variable used as array using an index)
If you change the code and delete the first foo variable (in function and in the call), this
won't crash (!)
I am still trying to simplify this code to find an immediate and obvious cause for the core dump,
but IMHO this script is yet simple enough to detect a problem.
<pre>
<?php
// will work without first dummy parameter
Function FooBar($foo,$depth=10,$bar=array()) {
if ($depth<0)
return "";
// echo ..
echo "in FooBar (".$depth.")\n";
// This part will cause damages soon
return FooBar($foo,$depth-1,$bar)
. FooBar2("",$bar)
. $foo["foo_bar"][13345879];
}
// will work without first dummy parameter
Function FooBar2($foo,$bar=array()) {
// This part shall seg fault ..
if (!$bar["foo_bar"]) {
$bar["foo_bar"]=$bar["foo_bar"]+1;
}
// echo ..
echo "in FooBar2 (".$foo.")\n";
// This part will cause memory damages..
$if_I_do_that_this_will_crash=serialize($bar);
return "";
}
FooBar("");
?>
</pre>
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14374&edit=1