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

Re: [perl #128597] SEGV caused by isLEXWARN_off while PL_curcop isNULL(gp_free vs dounwind).

Thread Previous | Thread Next
From:
Zefram
Date:
July 11, 2016 17:52
Subject:
Re: [perl #128597] SEGV caused by isLEXWARN_off while PL_curcop isNULL(gp_free vs dounwind).
Message ID:
20160711175244.GM1170@fysh.org
Father Chrysostomos via RT wrote:
>On Sun Jul 10 20:00:12 2016, hkoba@cpan.org wrote:
>> perl -e 'open my $fh, ">", \ (my $buf = ""); my $sub = eval q|sub
>> {die}|; $sub->()'
>
>Bisect:
>commit 96d7c88819733eaaba892177a967d9e898b2b924
>    [perl #57512] Warnings for implicitly closed handles

The crash is dependent on both $fh and $sub being lexical variables,
and on them being declared in that order.  What's interesting about this
requirement is that it means that $fh gets implicitly closed when the
pad is freed, and the crash only happens if $sub has already been freed
at that moment.  Indeed, another way to avert the crash is to stick a
reference to $sub into another lexical variable declared before $fh,
so it does seem to be order of freeing that matters.

Is there perhaps a reference to $sub on the context stack, which
gets followed into freed memory while processing the closure of $fh?
No warning is actually generated, but maybe the context is examined
while checking the warning flags?

-zefram

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