develooper Front page | perl.perl5.porters | Postings from December 2009

Re: [perl #71076] [PATCH] sort with active sub (5.10 regression)

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
December 7, 2009 06:06
Subject:
Re: [perl #71076] [PATCH] sort with active sub (5.10 regression)
Message ID:
b77c1dce0912070606j4c71a22bt150999ba6c512c4d@mail.gmail.com
2009/12/6 Father Chrysostomos <sprout@cpan.org>:
> One of the tests in sort.t causes a bus error (or sometimes ‘Undefined
> subroutine called’) if run multiple times:
>
> for(1..2)
>
> {
>    my $failed = 0;
>
>    sub rec {
>        my $n = shift;
>        if (!defined($n)) {  # No arg means we're being called by sort()
>            return 1;
>        }
>        if ($n<5) { rec($n+1); }
>        else { () = sort rec 1,2; }
>
>        $failed = 1 if !defined $n;
>    }
>
>    rec(1);
> }
>
> This is because sort decreases the refcount of an active sub used as a
> comparison routine.
>
> Ironically enough, this test was added by the very change that broke it
> (25953/9850bf2).
>
> The attached patch fixes this and also fixes a refcnt test that wasn’t
> testing was it purported to be testing, which almost lead me to introduce a
> new bug while fixing this one.

Thanks, applied in chunks :

commit 7f4622ecb46636e776e5a134c72847bbb795126c
Author: Rafael Garcia-Suarez <rgs@consttype.org>
Date:   Mon Dec 7 15:03:48 2009 +0100

    Fix a test that wasn’t testing was it purported to be testing

    (noticed by Father Chrysostomos, further modified to avoid using
    too much overloaded names like foo and Foo.)

commit 8a27a13e89107aaf68c0748b68ee71fbd86d774b
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Mon Dec 7 14:58:40 2009 +0100

    [perl #71076] sort with active sub (5.10 regression)

    One of the tests in sort.t causes a bus error (or sometimes ‘Undefined
    subroutine called’) if run multiple times. This is because sort
    decreases the refcount of an active sub used as a comparison routine.

    Ironically enough, this test was added by the very change that broke it
    (25953/9850bf2).

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