Re: PHP 4.0 Bug #8383: array_unique() causes core dump

From: Date: Fri, 29 Dec 2000 00:03:34 +0000
Subject: Re: PHP 4.0 Bug #8383: array_unique() causes core dump
References: 1 2 3 4  Groups: php.dev 
Request: Send a blank email to php-dev+get-42489@lists.php.net to get a copy of this message
Replying to myself again... On Sat, Dec 23, 2000 at 09:19:54PM +0100, Stig Venaas wrote: > On Sat, Dec 23, 2000 at 01:41:07PM +0100, Stig Venaas wrote: > > 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. > > As I thought, other array sorting functions are broken. For instance > sort() uses qsort with array_data_compare, the result is segfault on > Solaris. Since array_data_compare isn't a transitive relation, it I was a bit too quick here, just want to point out that the problem isn't array_data_compare but the compare function used. The user can solve this by adding a second argument to set another compare function than SORT_REGULAR. Still, it's not so good that users are able to get a segfault. Stig

« previous php.dev (#42489) next »