php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42419 array_sort bombs depending on input array
Submitted: 2007-08-24 23:25 UTC Modified: 2007-08-25 05:32 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bug at nyvegetarianexpo dot org Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.2.3 OS: Linux
Private report: No CVE-ID: None
 [2007-08-24 23:25 UTC] bug at nyvegetarianexpo dot org
Description:
------------
Depending on the array passed to it, the built in function array_sort will never return and all output after it be lost.  The code needed to reproduce this bug is embassingly simply.  It will bomb on an array of length two, but also others, but not all arrays.  It actually works for some.

I am not privy to all their compilation/configuration options, but I have run into this problem with two HSPs both on a linux box.  I can print_r(get_defined_constants()); if desired, however.

Reproduce code:
---------------
<HTML><TITLE>Array_sort bug test</TITLE><BODY>
<pre>
<?php
$a[] = '2007-09-15 10:00:00';
$a[] = '2007-09-15 16:00:00';
print_r($a);
echo "\nHANGS...\n";
array_sort($a);
print_r($a);
?>
</pre>
<b>No, it works!</b>
</BODY>
</HTML>

Expected result:
----------------
Array
(
    [0] => 2007-09-15 10:00:00
    [1] => 2007-09-15 16:00:00
)

HANGS...

Array
(
    [0] => 2007-09-15 10:00:00
    [1] => 2007-09-15 16:00:00
)

No, it works!

Actual result:
--------------
Array
(
    [0] => 2007-09-15 10:00:00
    [1] => 2007-09-15 16:00:00
)

HANGS...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-25 04:48 UTC] crrodriguez at suse dot de
There is no array_sort function in the PHP source code.. what are you talking about ?

functions are asort() and array_multisort and both work fine with your code..care to provide a working test ?
 [2007-08-25 05:28 UTC] bug at nyvegetarianexpo dot org
Oops, you are right.  Sorry.  I must have imagined the array_ suffix when I typed it into my script after looking up the function names for sort and array_unique!  The fact that it did not fail every time must have been due to my control structure in the original script and due to different arrays being passed.  I assume that it will work now with the correct name.  I will check.  Again, Sorry.  Big brain-malfunction!
 [2007-08-25 05:32 UTC] bug at nyvegetarianexpo dot org
"due to different arrays being passed" in my last comment should have been preceded by "NOT".  (I better get some sleep!)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC