ID: 22463 Updated by: [EMAIL PROTECTED] Reported By: mccannwj at pha dot jhu dot edu Status: Verified Bug Type: Arrays related Operating System: redhat-linux-8.0 PHP Version: 4.3.2-dev New Comment:
On my debian/ 4.3.2-dev it doesn't segfault. Valgring reports memoery read errors. Here is the script modified : <?php $a['one']['two']['three']['four'][] = array("FILE_NUMBER"=>2256, "INGEST_DATE"=>'2003-01-16'); $a['one']['two']['three']['four'][] = array("FILE_NUMBER"=>2258, "INGEST_DATE"=>'2003-01-17'); $num = nodeCount($a); print $num; function checkNode($v, $var) { var_dump($v, $var); echo str_repeat("-=",30)."\n"; if (is_scalar($var)) { $v += 1; } elseif (is_null($var)) { } else { echo "Recursy down\n"; $v += nodeCount($var); //$v = 2; echo "Recursy up\n"; } echo "checkNode - END\n"; return $v; } function nodeCount($array) { $number = 0; if (is_array($array)) { $number = array_reduce($array, "checkNode" , 0); } return $number; } ?> checkNode calls recursively itself. After getting of the recursy something bad happens at this line : zend_hash_move_forward_ex(Z_ARRVAL_PP(input), &pos); I think this is the line. Unfortunately I cannot help more atm. Previous Comments: ------------------------------------------------------------------------ [2003-02-27 15:50:07] [EMAIL PROTECTED] Updated version & verified ------------------------------------------------------------------------ [2003-02-27 15:08:05] mccannwj at pha dot jhu dot edu It core dumps when I run it from the command line. % gdb /usr/bin/php core.30270 [symbols blah blah] #0 0x0814c3d5 in zif_array_reduce () ------------------------------------------------------------------------ [2003-02-27 14:42:52] mccannwj at pha dot jhu dot edu 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 this bug report at http://bugs.php.net/?id=22463&edit=1