From: Operating system: Windows XP SP3 PHP version: 5.3.6 Package: Reproducible crash Bug Type: Bug Bug description:array_walk_recursive corruption
Description: ------------ I'm getting the crash in 5.3.6 and 5.3.7-dev from SVN. The initial code was part of an exception handler and its purpose was to generate a nicely formatted plain-text message to be emailed to me when there was an exception. I've reduced the code to the following example. No extensions required. Tested with 5.3.0 - 5.3.5 - all working fine. Tested with 5.3.6 and my own build 5.3.7-dev - crash. The specifics of this code is to take an array (a stripped down stack trace), and pad the elements so that they can be written out in a "table" format, all nicely vertically aligned. The crash comes during shutdown, not whilst running my code. Depending upon the amount of additional code, I can either get corrupted output or a crash. The "Expected result" below is for PHP 5.3.5 and the "Actual result" below is for PHP 5.3.6. Both are the official builds with no php.ini loaded. The current example just outputs corrupted data. Adding more code often results in an access violation. Test script: --------------- <?php function arrayPad(array &$data, array $alignments, array &$widths = Null) { $widths = array('name' => 7, 'age' => 2); echo 'Widths within ', __FUNCTION__, ' before array_walk_recursive ', var_export($widths, True), PHP_EOL; $b_Result = array_walk_recursive($data, function(&$value, $key) use($widths, $alignments) { $value = str_pad($value, $widths[$key], ' ', isset($alignments[$key]) ? $alignments[$key] : STR_PAD_RIGHT); }); echo 'Widths within ', __FUNCTION__, ' after array_walk_recursive ', var_export($widths, True), PHP_EOL; return $b_Result; } $alignments = array('age' => STR_PAD_LEFT); // Force the age to be right aligned. $data = array( // A list of names and ages. array('name' => 'Richard', 'age' => 43,), array('name' => 'Oscar', 'age' => 2,), ); arrayPad($data, $alignments, $widths); echo 'The data ', var_export($data, True), PHP_EOL, 'The alignments ', var_export($alignments, True), PHP_EOL, 'The widths returned by arrayPad ', var_export($widths, True); Expected result: ---------------- php-5.3.5\php -n -f err_001.php Widths within arrayPad before array_walk_recursive array ( 'name' => 7, 'age' => 2, ) Widths within arrayPad after array_walk_recursive array ( 'name' => 7, 'age' => 2, ) The data array ( 0 => array ( 'name' => 'Richard', 'age' => '43', ), 1 => array ( 'name' => 'Oscar ', 'age' => ' 2', ), ) The alignments array ( 'age' => 0, ) The widths returned by arrayPad array ( 'name' => 7, 'age' => 2, ) Actual result: -------------- php-5.3.6\php -n -f err_001.php Widths within arrayPad before array_walk_recursive array ( 'name' => 7, 'age' => 2, ) Widths within arrayPad after array_walk_recursive ! 1 ââ¨â²âºâº ⥠â ! Rich The data array ( 0 => array ( 'name' => 'Richard', 'age' => '43', ), 1 => array ( 'name' => 'Oscar ', 'age' => ' 2', ), ) The alignments array ( 'age' => 0, ) The widths returned by arrayPad array ( ) -- Edit bug report at http://bugs.php.net/bug.php?id=54470&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54470&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54470&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54470&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54470&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54470&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54470&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54470&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54470&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54470&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54470&r=support Expected behavior: http://bugs.php.net/fix.php?id=54470&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54470&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54470&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54470&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54470&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54470&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54470&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54470&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54470&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54470&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54470&r=mysqlcfg