develooper Front page | perl.perl5.porters | Postings from October 2018

Re: [perl #133558] perl 5.26: use lib pragma issue in IBM AIX

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
October 10, 2018 11:33
Subject:
Re: [perl #133558] perl 5.26: use lib pragma issue in IBM AIX
Message ID:
20181010112550.GN3102@iabyn.com
On Wed, Oct 10, 2018 at 10:52:24AM +0530, Gururaj Kallur wrote:
> (-e:1)  enteriter
>     =>
> (-e:1)  iter
>     =>  SV_NO

The iterator erroneously thinks that there's nothing left to iterate over.

I'd now like you to use a debugger to single-step through the
Perl_pp_iter() function, showing the path it takes, and also the values of
a couple of variables.  The lines of interest are these in pp_hot.c:

  2978	    case CXt_LOOP_ARY: /* for (@ary) */
  2979	
  2980	        av = cx->blk_loop.state_u.ary.ary;
  2981	        inc = 1 - (PL_op->op_private & OPpITER_REVERSED);
  2982	        ix = (cx->blk_loop.state_u.ary.ix += inc);
  2983	        if (UNLIKELY(inc > 0
  2984	                        ? ix > AvFILL(av)
  2985	                        : ix < 0)
  2986	        )
  2987	            goto retno;
  2988	
  2989	        if (UNLIKELY(SvRMAGICAL(av))) {

I think for some reason your machine is taking the 'goto retno' path.

Here's an annotated example session under gdb:

    $ gdb ./perl

Set a breakpoint and run the code:

    (gdb) b Perl_pp_iter
    (gdb) run -le '@a = qw(/foo/bar); for (reverse @a) { print }'
    Breakpoint 1, Perl_pp_iter (my_perl=0xacd260) at pp_hot.c:2865
    2865	{

Then single step through a few lines until 'inc' gets assigned to:

    (gdb) n
    2876	    cx = CX_CUR();
    (gdb) n
    2877	    itersvp = CxITERVAR(cx);
    (gdb) n
    2878	    assert(itersvp);
    (gdb) 
    2880	    switch (CxTYPE(cx)) {
    (gdb) 
    2980	        av = cx->blk_loop.state_u.ary.ary;
    (gdb) n
    2981	        inc = 1 - (PL_op->op_private & OPpITER_REVERSED);
    (gdb) 
    2982	        ix = (cx->blk_loop.state_u.ary.ix += inc);

Then display the current value of inc, and also show its type:

    (gdb) p inc
    $1 = 0xffffffffffffffff
    (gdb) ptype inc
    type = long

Then execute the next line (which assigns to ix) and show that var's info
too:

    (gdb) n
    2983	        if (UNLIKELY(inc > 0
    (gdb) p ix
    $2 = 0x0
    (gdb) ptype ix
    type = long

Now call the sv_dump() function to show what the array being iterated over
looks like:

    (gdb) call Perl_do_sv_dump(my_perl, 0, Perl_PerlIO_stderr(my_perl), av, 0, 4, 0, 200)
    SV = PVAV(0xad1f90) at 0xaff9e8
      REFCNT = 2
      FLAGS = ()
      ARRAY = 0xaf4408
      FILL = 0
      MAX = 3
      FLAGS = (REAL)
        Elt No. 0
        SV = PV(0xad0df8) at 0xad0228
          REFCNT = 1
          FLAGS = (POK,IsCOW,pPOK)
          PV = 0xafdd88 "/foo/bar"\0
          CUR = 8
          LEN = 10
          COW_REFCNT = 1

Finally, execute the conditional test, and see which branch it takes.
On a 'good' system the test condition is false and so it ends up on this
line:

    (gdb) n
    2989	        if (UNLIKELY(SvRMAGICAL(av))) {
    (gdb) 


-- 
This email is confidential, and now that you have read it you are legally
obliged to shoot yourself. Or shoot a lawyer, if you prefer. If you have
received this email in error, place it in its original wrapping and return
for a full refund. By opening this email, you accept that Elvis lives.

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