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

Re: [perl #39358] sort with custom subname and prototype ($$)segfaults intermittently

From:
Karl Williamson
Date:
August 10, 2016 17:49
Subject:
Re: [perl #39358] sort with custom subname and prototype ($$)segfaults intermittently
Message ID:
cd24d43a-2aa9-54c9-f58f-6b17203831ef@khwilliamson.com
On 08/10/2016 09:36 AM, Dave Mitchell wrote:
> On Sun, Sep 26, 2010 at 02:39:49PM -0700, Father Chrysostomos via RT wrote:
>> On Thu Jun 08 21:23:40 2006, johnh@isi.edu wrote:
>>> #!/usr/bin/perl -w
>>>
>>> @scores = (
>>>   '0000.0000.00039:0000.0008.0031.',
>>>   '0000.0000.00032:0000.0008.0024.',
>>>   '0002.0002.00033:0002.0011.0020.',
>>>   '0028.0028.00190:0077.0085.0028.');
>>>
>>> @match_indices = (0,1,2,3);
>>> sub sort_by_index($$) {
>>>     my($A,$B) = @_;
>>>     return $scores[$match_indices[$A]] cmp
>>>    $scores[$match_indices[$B]];
>>> }
>>> @match_indices = sort sort_by_index @match_indices;
>>> ----------------------------------------
>>
>> This gives me:
>> Bizarre copy of UNKNOWN in aelem at - line 12.
>> in commit 42bd538f820268331bc55a66fa9df0673de69250
>>
>> d963bf01c4c4db296760b1148f98bf668efcaf58, three commits later (the
>> intervening commits affecting only documentation), gives
>> Use of uninitialized value $match_indices[2] in array element at - line 12.
>> Use of uninitialized value $match_indices[2] in array element at - line 12.
>> Use of uninitialized value $match_indices[0] in array element at - line 12.
>>
>> but I can’t see how it fixes it.
>
> Fixed now in blead by the following. The issue was as the bit below about
> mergesort leaving random pointers lying about.
>
> commit 84721d614eb7d9835d9a09505b0001c7be40a865
> Author:     David Mitchell <davem@iabyn.com>
> AuthorDate: Wed Aug 10 15:12:56 2016 +0100
> Commit:     David Mitchell <davem@iabyn.com>


blead is failing to compile for me unless I revert this, with the message:

pp_sort.c: In function ‘OP* Perl_pp_sort(PerlInterpreter*)’:
pp_sort.c:1599:26: error: invalid conversion from ‘OP* {aka op*}’ to 
‘char’ [-fpermissive]
      copytmps = PL_sortcop;







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