Re: [PHP4BETA] (Fwd) Re: [PHP4BETA] cvs: /php4 ChangeLog /php4/ext/standardbasic_functions.c basic_functions.h

From: Date: Fri, 08 Oct 1999 15:13:19 +0000
Subject: Re: [PHP4BETA] (Fwd) Re: [PHP4BETA] cvs: /php4 ChangeLog /php4/ext/standardbasic_functions.c basic_functions.h
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-5398@lists.php.net to get a copy of this message
That depends on who you ask... When I contacted our Sun rep about this, the word I got was that this is not broken at all because qsort should not be used for a non-deterministic comparison. They felt that this was perfectly appropriate behaviour, and other libc implementations got away with it because they do not check it more than once as the sun libc does. Who knows, I think there would be much better ways to deal with it than segfaulting, but Sun does not and has told me that this is not a bug and will not ever be addressed. Rasmus Lerdorf wrote: > > qsort() on Solaris seems pretty broken to me. When you feed it a > non-causal comparison function, it sometimes screws up. > > For example, try this test broken on both Linux and Solaris: > > #include <stdio.h> > #include <stdlib.h> > #include <time.h> > > static int cmp(const void *a, const void *b) { > return( (rand()%2) ? -1 : 1 ); > } > > int main(void) { > int i,l; > char *foo = malloc(32); > > srand(time(NULL)); > for(i=0;i<1000;i++) { > strcpy(foo,"AAABBBAAABBBAAABBBAAABBB"); > l=strlen(foo); > qsort(foo,l,1,cmp); > if(strlen(foo)!=l) printf("Broken!\n"); > else printf("%s\n",foo); > } > } > > Run it a few times and grep its output for "Broken". You will notice that > it never says Broken on Linux but just about always has a couple of Broken > lines on Solaris. > > -Rasmus > > -- > PHP 4 Beta -- Chad Cunningham ccunning@math.ohio-state.edu Physicists think the real world models equations. Engineers think equations model the real world. Mathematicians fail to make the connection.

« previous php.version4 (#5398) next »