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

Re: [perl #128253] Assert fail in S_find_uninit_var (viaPerl_pp_multideref) without other symptoms: $ISA[0][0]

Thread Previous
From:
Dave Mitchell
Date:
July 7, 2016 15:43
Subject:
Re: [perl #128253] Assert fail in S_find_uninit_var (viaPerl_pp_multideref) without other symptoms: $ISA[0][0]
Message ID:
20160707154309.GQ17054@iabyn.com
On Thu, May 26, 2016 at 05:08:31PM -0700, Dan Collins wrote:
> dcollins@nightshade64:~/perldebug$ ./perl -Ilib -W -e '$ISA[0][0]'
> Useless use of array element in void context at -e line 1.
> perl: sv.c:16093: S_find_uninit_var: Assertion `is_hv' failed.
> Aborted

Fixed by the below:

commit 6fe82bd6d07db28c9792126ff851a29fe013401c
Author:     David Mitchell <davem@iabyn.com>
AuthorDate: Thu Jul 7 16:24:41 2016 +0100
Commit:     David Mitchell <davem@iabyn.com>
CommitDate: Thu Jul 7 16:24:41 2016 +0100

    handle magic in multideref "unit val" var names
    
    [perl #128253] Assert fail in S_find_uninit_var
    
        $ perl5240 -we'$ISA[0][0]'
        Useless use of array element in void context at -e line 1.
        perl5240: sv.c:16078: S_find_uninit_var: Assertion `is_hv' failed.
    
    The code in find_uninit_var() which looks for a variable name associated
    with an uninitialized value assumed, in the OP_MULTIDEREF branch, that the
    value was either an index if the op was top-level ($foo[$uninit]), or an
    array/hash element otherwise (1+$foo[...]).
    
    It turns out here's a third possibility: magic. In $ISA[0][0], the first
    array lookup is in lval context, so it initially autovivifies to undef.
    Normally it would shortly afterwards be upgraded to a ref to an empty AV,
    but first ISA set magic for @ISA is invoked. This ends up scanning @ISA
    and finds an uninit value which it tries to use as a key into the stash
    cache, triggering an ununit value warning.
    
    This commit expands the OP_MULTIDEREF code in find_uninit_var() to handle
    this third possibility - chiefly by not returning a variable name unless
    the index var is the same SV as the uninit value. As well as fixing the
    assert failure in this ticket, it also stops printing an incorrect index in
    code like this:
    
        $ perl -we'my $i = 0; $ISA[$i] = 1'
    
    before:
    
        ....
        Use of uninitialized value $i in array element at -e line 1.
        Use of uninitialized value $i in array element at -e line 1.
        Recursive inheritance detected in package 'main' at -e line 1.
    
    after:
    
        ....
        Use of uninitialized value in array element at -e line 1.
        Use of uninitialized value in array element at -e line 1.
        Recursive inheritance detected in package 'main' at -e line 1.
    
    @ISA magic still has recursion issues with undef values, as can be seen
    above. I don't address those issues here. Because of that, I haven't
    been able to add tests.


-- 
Any [programming] language that doesn't occasionally surprise the
novice will pay for it by continually surprising the expert.
   -- Larry Wall

Thread Previous


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