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

DAVEM TPF bug-grant report #164

Dave Mitchell
May 1, 2013 14:16
DAVEM TPF bug-grant report #164
Message ID:
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:

    use Carp;
    sub f3 { croak() }
    sub f2 { "a" =~ /a(?{f3(3)})/ }
    sub f1 { f2(2) }

gives the following results:

	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

	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

	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


    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


[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" Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About