develooper Front page | perl.perl5.porters | Postings from August 2001

Re: [ID 20010821.007] sort stupidness caused segfault

Thread Previous | Thread Next
From:
Abigail
Date:
August 22, 2001 15:25
Subject:
Re: [ID 20010821.007] sort stupidness caused segfault
Message ID:
20010822222400.9912.qmail@foad.org
On Wed, Aug 22, 2001 at 07:17:07AM -0400, John P. Linderman wrote:
> > 
> > This is a bug report for perl from root@ws.com.au,
> > generated with the help of perlbug 1.33 running under perl v5.6.1.
> > 
> > 
> > -----------------------------------------------------------------
> > [Please enter your report here]
> > 
> > just stuffing around being stupid with sort {} and ..
> > 
> > gateway:~/tmp# cat rand
> > #!/usr/bin/perl
> > @a = (1, 2, 3, 4, 5, 6, 7, 8, 9);
> > @a = sort {
> >         @a = sort {
> >                 @a = sort {
> >                         @a = sort {
> >                                 int rand (2) - 2;
> >                         }
> >                         int rand (2) - 2;
> >                 }
> >                 int rand (2) - 2;
> >         } @a;
> >         int rand (2) - 2;
> > } @a;
> > print join '', @a;
> > gateway:~/tmp# ./rand
> > Segmentation fault
> 
> I don't think this is directly related to sort because
> a) it happens both with the 5.6 qsort and the 5.7 merge sort and
> b) it goes away if you pass @a to the two innermost invocations
>    (as is done on the outermost invocations) before returning the
>    random value.
> 
> Still, as the documentation says,
>    The comparison function is required to behave.

If you replace all the occurances of 'int rand (2) - 2' in the above
code with 0, it still core dumps.

My guess is that the problem is the modification of @a during the sort.



Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About