nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

Moose meta->make_immutable SEGV on empty $compile_around_method method #371

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Simple Moose program:
#!/usr/bin/perl

package foo;
use Moose;

has 'x' => (isa => 'Int', is => 'rw', required => 1);
has 'y' => (isa => 'Int', is => 'rw', required => 1);

sub clear {
    my $self = shift;
    $self->x(0);
    $self->y(0);
}

__PACKAGE__->meta->make_immutable;
package main;

my $f = foo->new( x => 5, y => 6);
print $f->x . "\n";

What is the expected output? What do you see instead?
EXPECT:
$>perl foo.pl
5

GOT:
$>perlcc -O3 foo.pl
pcc6RlrX.c:111961: warning: integer constant is too large for ‘unsigned 
long’ type
$>./foo
zsh: segmentation fault  ./foo

This is compiling against master running against perl 5.14.4

current master sha: commit 188fc56d2aeaea027111650fff9b7f58e93456e6

Original issue reported on code.google.com by todd.e.rinaldo on 22 Aug 2014 at 8:51

GoogleCodeExporter commented 9 years ago
It looks like the magic incantation is causing the problem. Taking it out makes 
the program work as expected:

__PACKAGE__->meta->make_immutable;

Original comment by todd.e.rinaldo on 22 Aug 2014 at 8:53

GoogleCodeExporter commented 9 years ago

Original comment by todd.e.rinaldo on 22 Aug 2014 at 8:55

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 22 Aug 2014 at 2:50

GoogleCodeExporter commented 9 years ago
It cannot find the $orig method when in Class/MOP/Class/Immutable/Trait.pm:90 
{__immutable}{_method_map} is empty. $orig is 0x0. 

It should be the $f1 in the anonsub in Class/MOP/Method/Wrapped.pm:162
sub { $f2->( $f1, @_ ) }
$f2 is the &_method_map
$f1 is pop'ed from @_ of $compile_around_method.

Original comment by reini.urban on 22 Aug 2014 at 3:03

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 22 Aug 2014 at 3:04