Re: panic: attempt to copy freed scalar caused by calling cgi->param with TryCatch since perl 5.19.7

Steve Hay <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CADED=K6MWUc91_-TQO8SLuuV0_WOpruKbi2hnYJVR-h3NiYN6w@mail.gmail.com>
On 15 September 2015 at 23:15, Michael Schout <[email protected]> wrote:
> As reported in other thread, I've seen mod_perl emit panic warnings such
> as the following ever since 5.19.7:
>
>  panic: attempt to copy freed scalar 7fb2264ffde0 to 7fb2264ffd08 at
> /Users/mschout/Sync/Apache-TryCatch/blib/lib/Apache/TryCatch.pm line 20.
>
> I've also seen random segementation faults caused by innocent looking
> "return" statements in a large code base.
>
[...]
>
> I bisected against perl git, using mod_perl 2.0.9 and apache 2.2.29 as
> the mod_perl environment, and installing TryCatch from cpan, and
> discovered that the following perl commit is the culprit:
>
>> commit 437e3a7dac994ebace1195549170c81f474d9c20
>> Author: Matthew Horsfall <[email protected]>
>> Date:   Wed Dec 11 18:28:21 2013 -0500
>>
>>     Optimise out PUSHMARK/RETURN if return is the last statement in a sub.
>>
>>     This makes:
>>
>>       sub baz { return $cat; }
>>
>>     Behave like:
>>
>>       sub baz { $cat; }
>>
>>     Which is notably faster.
>>

Thanks for the detective work, Michael. I've logged this on
rt.perl.org since it isn't yet clear whether the optimization has a
problem, or whether mod_perl (or maybe TryCatch / Devel::Declare) is
doing anything naughty:

https://rt.perl.org/Ticket/Display.html?id=126070
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.