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

[perl #118043] Segmentation fault with a delete call inside chained prototyped sub calls

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
May 18, 2013 00:06
Subject:
[perl #118043] Segmentation fault with a delete call inside chained prototyped sub calls
Message ID:
rt-3.6.HEAD-2650-1368835598-296.118043-15-0@perl.org
On Fri May 17 16:52:56 2013, boyd.paul2@gmail.com wrote:
> This is a bug report for perl from boyd.paul2@gmail.com,
> generated with the help of perlbug 1.39 running under perl 5.16.3.
> 
> 
> -----------------------------------------------------------------
> I'm not sure how to explain this in words, here's the code:
> 
> sub a(&&) {};
> sub b(&) {};
> a {} b { delete $x };
> 
> [pboyd@pboyd ~]$ perl -E 'sub a(&&) {}; sub b(&) {}; a {} b { delete
> $x };'
> delete argument is not a HASH or ARRAY element or slice at -e line 1.
> Segmentation fault
> 
> I've tried this on v5.12.1, v5.16.1 and v5.16.3, perl segfaults on all
> of
> them.
> 
> It seems to be related to the prototypes, specifically using sub {}
> make the
> segfault go away. Also just a single prototyped call ("a { delete $x
> }"),
> doesn't segfault either.
> 
> I ran into this with Try::Tiny, when I mistakenly did a "delete $foo"
> inside
> the catch block, something like this:
> 
> perl -E 'use Try::Tiny; try {} catch { delete $x }'
> 

The segmentation fault -- or, perhaps more precisely, the *report* of a
segmentation fault -- is something specific to your operating
system/platform.  I was able to get the same error message and notice of
segfault that you did when I ran it on Linux/i386.

However, when I ran it on Darwin/PPC, I got only the error message -- no
notice of segfault.

But, IMO, the segfault is irrelevant.   Your code fails to compile:

#####
$ cat 118043-proto.pl 
use 5.010_001;

sub a(&&) {};
sub b(&) {};
a {} b { delete $x };

$ perl -c 118043-proto.pl
delete argument is not a HASH or ARRAY element or slice at
118043-proto.pl line 5.
#####

This is not a bug in Perl.

Closing ticket.

Thank you very much.
Jim Keenan

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

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