php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28743 array_udiff dumps core
Submitted: 2004-06-11 18:17 UTC Modified: 2005-01-23 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rodolfo at rodsoft dot org Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5.0.0RC2 OS: linux 2.6.6
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-06-11 18:17 UTC] rodolfo at rodsoft dot org
Description:
------------
If you run the following script with your web browser and reload the page a couple of times, php dumps core. My apache version is 2.0.49 with libphp dynamically linked.

Strangely enough, if you change the array index inside the create_function to something bogus, like "d", array_udiff returns an empty array (without issuing an error). The second time the script is called, as usual, php dumps core. With the correct array index, the output is ok the first time. But dumps core the second time is called.

Reproduce code:
---------------
<?
    $p1[] = array('a'=>1, 'b'=>'apple');
    $p1[] = array('a'=>2, 'b'=>'orange');
    $p1[] = array('a'=>3, 'b'=>'banana');
    $p2[] = array('a'=>3, 'b'=>'banana');
    $p2[] = array('a'=>4, 'b'=>'raspberry');

    echo "<pre>";
    print_r(array_udiff($p1, $p2,create_function('$a,$b',
			'return $a["a"]-$b["a"];')));
    echo "</pre>";
?>

Expected result:
----------------
Array
(
    [0] => Array
        (
            [a] => 1
            [b] => apple
        )

    [1] => Array
        (
            [a] => 2
            [b] => orange
        )
)

no matter how many times we run the script

Actual result:
--------------
The correct result in the first time the script is run, and the following core dump backtrace the second time:

#0 0x00000001 in ?? ()
#1 0x4072bc0a in zend_call_function () from /usr/lib/apache/libphp5.so
#2 0x4067dd81 in array_user_compare () from /usr/lib/apache/libphp5.so
#3 0x407458c9 in zend_qsort() from /usr/lib/apache/libphp5.so
#4 0x40684a19 in php_array_diff () from /usr/lib/apache/libphp5.so
#5 0x00000003 in ?? ()
#6 0x00000004 in ?? ()
#7 0x4067dcf0 in zif_rsort() from /usr/lib/apache/libphp5.so
Previous frame inner to this frame (corrupt stack?)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-15 00:09 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip

Seems to be fixed, as I can reproduce with latest 5.* snapshots.
 [2005-01-23 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-04-10 05:07 UTC] vinoth at goodluckdomain dot com
test
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC