From: mccannwj at pha dot jhu dot edu
Operating system: redhat-linux-8.0
PHP version: 4.2.3
PHP Bug Type: Reproducible crash
Bug description: array_reduce segmentation fault
Using array_reduce on a nested list causes a segfault.
The following code isolates the problem.
<?php
$a['ANY']['F550M']['HRC']['j6jt01dlq_flt.fits'][] =
array("FILE_NUMBER"=>2256,
"INGEST_DATE"=>'2003-01-16');
$a['ANY']['F550M']['HRC']['j6jt01dll_flt.fits'][] =
array("FILE_NUMBER"=>2258,
"INGEST_DATE"=>'2003-01-17');
$num = nodeCount($a);
print $num;
function checkNode($v,$var) {
print "<pre>";
print_r($var);
print "</pre>";
if (is_scalar($var)) {
$v += 1;
}
elseif (is_null($var)) {
}
else {
$v += nodeCount($var);
}
return $v;
}
function nodeCount($array) {
$number = 0;
if (is_array($array))
$number = array_reduce($array,"checkNode",0);
return $number;
}
?>
How reproducible:
Always
Steps to Reproduce:
1. Execute code snippet
Actual Results: apache error_log:
[Fri Feb 21 12:52:52 2003] [notice] child pid 5618 exit signal
Segmentation
fault (11)
Expected Results: This code should count the scalar nodes in the nested
list.
It should print the number 4.
Additional info:
--
Edit bug report at http://bugs.php.net/?id=22463&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=22463&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=22463&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=22463&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=22463&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=22463&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=22463&r=support
Expected behavior: http://bugs.php.net/fix.php?id=22463&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=22463&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=22463&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=22463&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22463&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=22463&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=22463&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=22463&r=gnused