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

[perl #119051] SEGFAULT when trying to reference a non-code ref as a code ref

Thread Next
From:
Father Chrysostomos via RT
Date:
July 28, 2013 15:10
Subject:
[perl #119051] SEGFAULT when trying to reference a non-code ref as a code ref
Message ID:
rt-3.6.HEAD-2552-1375024202-831.119051-15-0@perl.org
On Sun Jul 28 07:21:40 2013, kentfredric@gmail.com wrote:
> The following code snippet causes Perl to segfault :
> 
> $Foo::nosub  = undef;
> my $ref =  *Foo::->{nosub};

What you have there is a glob, not a reference.

> my $deref = \&$ref;

It was probably this commit that caused it:

commit 186a5ba82d5844e9713475c494fcd6682968609f
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Wed Jun 13 22:46:40 2012 -0700

    Don’t create pads for sub stubs

The bug can be reduced to this:

$ref = *Foo::nosub;
\&$ref;

The assignment creates a glob copy (coercible glob; one that downgrades
back to a simple scalar when assigned to).

\&$ref autovivifies a stub in that glob.

Stub autovivification used to stringify the glob, look it up again by
name, and then vivify the stub in the glob.

I removed what seemed like a waste of CPU cycles, but apparently it
served some purpose.

I suspect the correct fix is to do stringfy-and-lookup if the glob is
coercible (SvFAKE).

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=119051

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