develooper Front page | perl.perl5.porters | Postings from May 2013

DAVEM TPF bug-grant report #164

From:
Dave Mitchell
Date:
May 1, 2013 14:16
Subject:
DAVEM TPF bug-grant report #164
Message ID:
20130501141428.GD2216@iabyn.com
This week I fixed how caller() and __SUB__ work within regex code blocks
(and I was on holiday for the latter part of the week).

It turns out that since my re_eval jumbo fix, code blocks in literal
matches were displaying an extraneous extra stack frame. This code:

    #!/usr/bin/perl
    use Carp;
    sub f3 { croak() }
    sub f2 { "a" =~ /a(?{f3(3)})/ }
    sub f1 { f2(2) }
    f1(1);

gives the following results:

5.16.3:
	main::f3(3) called at (re_eval 1) line 1
	main::f2(2) called at /home/davem/tmp/p line 6
	main::f1(1) called at /home/davem/tmp/p line 7

5.17.10:
	main::f3(3) called at /home/davem/tmp/p line 5
	main::f2 called at /home/davem/tmp/p line 5
	main::f2(2) called at /home/davem/tmp/p line 6
	main::f1(1) called at /home/davem/tmp/p line 7

blead:
	main::f3(3) called at /home/davem/tmp/p line 5
	main::f2(2) called at /home/davem/tmp/p line 6
	main::f1(1) called at /home/davem/tmp/p line 7

In addition, the __SUB__ token, which returns a reference to the current
subroutine, was returning a ref to the hidden anonymous sub which is
now used to implement closure behaviour correctly for code blocks within
qr//'s; that is,

    $r = qr/foo(?{...})bar/;

is supposed to behave like

    $r = sub { /foo/  && do {...} && /bar/ }

as far as closures are concerned. The trouble is, the anon sub was never
designed to be called directly, and in fact perl SEGVs if you do attempt
to call it. The workaround for this is to skip regex calls on the context
stack when looking for the CV for __SUB__; this has the effect of __SUB__
always returning the sub which executed the pattern match, regardless
of what direct code blocks (/(?{})/), or indirect code blocks (
$r = qr/(?{})/; /a$r/ ) have been called. I have documented this as
subject to change for now.


Report for period 2013/04/22 to 2013/04/28 inclusive

SUMMARY
-------

    Effort (HH::MM):

        2:21 diagnosing bugs
        4:27 fixing bugs
        0:00 reviewing other people's bug fixes
        0:00 reviewing ticket histories
        0:00 review the ticket queue (triage)
       -----
        6:48 TOTAL

    Numbers of tickets closed:

           1 tickets closed that have been worked on
           0 tickets closed related to bugs that have been fixed
           0 tickets closed that were reviewed but not worked on (triage)
       -----
           1 TOTAL


DETAIL
------

[perl #113928] caller behaving unexpectedly in re-evals

    2013/04/23  2:21 diag
    2013/04/24  4:27 fix
    2013/04/24     - close


-- 
O Unicef Clearasil!
Gibberish and Drivel!
    -- "Bored of the Rings"



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