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
Father Chrysostomos via RT
July 28, 2013 15:10
[perl #119051] SEGFAULT when trying to reference a non-code ref as a code ref
Message ID:
On Sun Jul 28 07:21:40 2013, 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 <>
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;

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

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About