Date: 12/23/00
- Next message: been500mls <email protected>: "[PHP-DEV] Play Vegas in your own House!!!!!"
- Previous message: cynic <email protected>: "[PHP-DEV] PHP 4.0 Bug #8388 Updated: 4.0.4 fails on basic authentication"
- In reply to: Sascha Schumann: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Next in thread: Stig Venaas: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Reply: Stig Venaas: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Reply: Stig Venaas: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Dec 23, 2000 at 01:26:07AM +0100, Sascha Schumann wrote:
> > array_unique(array("socket", "370", "99", "3d"));
>
> With the above input, qsort sees this:
>
> "socket" > "3d" (due to string comparison)
> ^ "3d" > "370" (string)
> ^ "370" > "99" (int)
> ^ "99" > "3d" (string)
>
> That violates the rule "a > b ^ b > c => a > c". Solaris'
> qsort does not like that and causes a segfault.
Right, I see. Interesting problem, this might be a problem for someone
doing sorting in PHP as well. I changed the code for array_unique, to
use what I called array_type_data_compare instead of array_data_compare
two months ago; after 4.0.3pl1 was released I think. It should fix this
since it compares type first, so that numeric types are always smaller
than strings. The order should then be:
socket > 3d > 370 > 99
Reason I changed it, was that I didn't like what happened if I did
say array_unique(array(0, "a", "b"));
I did the same for array_intersect and array_diff too.
There are other functions like asort() that does
zend_hash_sort(target_hash, qsort, array_data_compare,0)
I think they have the same problem. If they do, they should probably
use array_type_data_compare instead. According to the description of
array_data_compare in array.c numbers are always smaller than strings,
but array_data_compare has been changed so that this is not the case
any more, that's why I put in array_type_data_compare. Actually it
might be that array_data_compare is useless as it is.
Stig
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: been500mls <email protected>: "[PHP-DEV] Play Vegas in your own House!!!!!"
- Previous message: cynic <email protected>: "[PHP-DEV] PHP 4.0 Bug #8388 Updated: 4.0.4 fails on basic authentication"
- In reply to: Sascha Schumann: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Next in thread: Stig Venaas: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Reply: Stig Venaas: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Reply: Stig Venaas: "Re: [PHP-DEV] PHP 4.0 Bug #8383: array_unique() causes core dump"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

