Skip Menu |
 

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 78291
Status: rejected
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: fs5 [...] sanger.ac.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: missing curly brackets in attribute declaration can lead to segmentation fault
Date: Tue, 10 Jul 2012 11:50:42 +0100
To: bug-Moose [...] rt.cpan.org
From: Frank Schwach <fs5 [...] sanger.ac.uk>
Download (untitled) / with headers
text/plain 1.3k
Perl 5.8.8 Moose 2.0603 my OS: Linux version 2.6.32-bpo.4-amd64 (Debian 2.6.32-11~bpo50+1) How to replicate: package TestMe; use warnings; use strict; use Moose; has atr => ( isa => 'Integer', is => 'ro', required => 0, lazy => 1, default => sub { my $self = shift; return $self->foo if $self->foo ; ); __PACKAGE__->meta->make_immutable; 1; run it: $ perl -MTestMe -e "TestMe->new" Segmentation fault The real error, the missing curly bracket that should end the default "sub" block, is not detected and I get a seg fault instead. This only happens when trying to make immutable and only if I use "return $self->foo if $self->foo ;" Changing that line to "return $self->foo;" gives me: $ perl -MTestMe -e "TestMe->new" panic: pad_swipe curpad at TestMe.pm line 24. Compilation failed in require. BEGIN failed--compilation aborted. which is still a bit opaque but at least it's clearly a compilation error now. This is probably a very rare case but the resulting error is very weird indeed. Thanks for looking into this! Frank -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
Subject: Re: [rt.cpan.org #78291] missing curly brackets in attribute declaration can lead to segmentation fault
Date: Tue, 10 Jul 2012 09:15:00 -0500 (CDT)
To: Frank Schwach via RT <bug-Moose [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
Download (untitled) / with headers
text/plain 1.2k
On Tue, 10 Jul 2012, Frank Schwach via RT wrote: Show quoted text
> $ perl -MTestMe -e "TestMe->new" > Segmentation fault > > The real error, the missing curly bracket that should end the default > "sub" block, is not detected and I get a seg fault instead. > > This only happens when trying to make immutable and only if I use > "return $self->foo if $self->foo ;" > > Changing that line to > "return $self->foo;" > > gives me: > $ perl -MTestMe -e "TestMe->new" > panic: pad_swipe curpad at TestMe.pm line 24. > Compilation failed in require. > BEGIN failed--compilation aborted. > > which is still a bit opaque but at least it's clearly a compilation > error now. This is probably a very rare case but the resulting error is > very weird indeed.
This error is coming from Perl itself, not Moose. I doubt there's anything we could do to fix it in Moose. I tested with a few different Perl versions, and this only happens with 5.8.x, which is about 6 years old at this point. There's a lot of improvements in more recent versions besides fixing this segfault. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.