rurban / perl-compiler

B::C - Moved over from googlecode
https://code.google.com/p/perl-compiler/
Other
63 stars 23 forks source link

Moose compilation issues #338

Open atoomic opened 8 years ago

atoomic commented 8 years ago

Exception and segfault when compiling a simple Moose program

1/ Exception with perl5.22 debug and a simple moose program

package Animal;
use Moose;
has 'name'   => ( isa => 'Str', is => 'rw', required => 1 );

package main;
my $a = Animal->new( name => "unicorn");
print $a->name()."\n";
> rm -f test; perlcc test.pl; ./test
test: hv.c:2784: S_unshare_hek_or_pvn: Assertion `he->shared_he_he.hent_hek == hek' failed.
Aborted
Starting program: /root/workspace/bc/test
[Thread debugging using libthread_db enabled]
test: hv.c:2784: S_unshare_hek_or_pvn: Assertion `he->shared_he_he.hent_hek == hek' failed.

Program received signal SIGABRT, Aborted.
0x00130416 in __kernel_vsyscall ()
(gdb) bt
#0  0x00130416 in __kernel_vsyscall ()
#1  0x0063c871 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x0063e14a in abort () at abort.c:92
#3  0x00635b8b in __assert_fail_base (fmt=0x76ae98 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x50dd20 "he->shared_he_he.hent_hek == hek", file=0x50d3eb "hv.c", line=2784, function=0x50e910 "S_unshare_hek_or_pvn")
    at assert.c:96
#4  0x00635c46 in __assert_fail (assertion=0x50dd20 "he->shared_he_he.hent_hek == hek", file=0x50d3eb "hv.c", line=2784,
    function=0x50e910 "S_unshare_hek_or_pvn") at assert.c:105
#5  0x002d4aa8 in S_unshare_hek_or_pvn (hek=0x8e0d480, str=0x0, len=0, hash=0) at hv.c:2784
#6  0x002d4a34 in Perl_unshare_hek (hek=0x8e0d480) at hv.c:2758
#7  0x00325359 in S_sv_uncow (sv=0x8d69dbc, flags=5) at sv.c:5247
#8  0x0032540c in Perl_sv_force_normal_flags (sv=0x8d69dbc, flags=5) at sv.c:5280
#9  0x0038deda in Perl_leave_scope (base=483) at scope.c:1045
#10 0x00386eab in Perl_pop_scope () at scope.c:104
#11 0x002f1b63 in Perl_pp_leavesub () at pp_hot.c:2998
#12 0x0028f5bb in Perl_runops_debug () at dump.c:2234
#13 0x0019fd72 in S_run_body (oldscope=1) at perl.c:2448
#14 0x0019f325 in perl_run (my_perl=0x8d8e008) at perl.c:2371
#15 0x089179cb in main ()

2/ Segfault when using MooseX::Getopt

package Animal;
use Moose;
with 'MooseX::Getopt';
has 'name'   => ( isa => 'Str', is => 'rw', required => 1 );

package main;
run() unless caller;
sub run
{
    my $a = Animal->new( name => "unicorn");
    print $a->name()."\n";
}
Program received signal SIGSEGV, Segmentation fault.
0x002f254d in Perl_pp_entersub () at pp_hot.c:3046
3046    pp_hot.c: No such file or directory.
    in pp_hot.c
(gdb) bt
#0  0x002f254d in Perl_pp_entersub () at pp_hot.c:3046
#1  0x0028f5bb in Perl_runops_debug () at dump.c:2234
#2  0x007dd85e in XS_List__Util_first (cv=0x9423fb4) at ListUtil.xs:387
#3  0x002f4fba in Perl_pp_entersub () at pp_hot.c:3270
#4  0x0028f5bb in Perl_runops_debug () at dump.c:2234
#5  0x001a12ce in Perl_call_sv (sv=0x944fef0, flags=13) at perl.c:2755
#6  0x001aaddd in Perl_call_list (oldscope=15, paramList=0x944fdc4) at perl.c:4846
#7  0x00180e86 in S_process_special_blocks (floor=425, fullname=0x8ea478c "BEGIN", gv=0x944ffa4, cv=0x944fef0) at op.c:8891
#8  0x001806b7 in Perl_newATTRSUB_x (floor=425, o=0x9415544, proto=0x0, attrs=0x0, block=0x9415524, o_is_gv=false) at op.c:8821
#9  0x0016ff4b in Perl_utilize (aver=1, floor=425, version=0x9456294, idop=0x94562b4, arg=0x0) at op.c:6043
#10 0x00215027 in Perl_yyparse (gramtype=258) at perly.y:351
#11 0x003aa0b8 in S_doeval (gimme=2, outside=0x0, seq=6861, hh=0x0) at pp_ctl.c:3491
#12 0x003b096c in Perl_pp_require () at pp_ctl.c:4176
#13 0x0028f5bb in Perl_runops_debug () at dump.c:2234
#14 0x0019fd72 in S_run_body (oldscope=1) at perl.c:2448
#15 0x0019f325 in perl_run (my_perl=0x8d8e008) at perl.c:2371
#16 0x08917fba in main ()
rurban commented 8 years ago

Moose never worked with perlcc, and without fixing Moose it probably never will. They did conceptionally everything wrong and they have no idea about compilation phases. E.g. their compile-time optimizations do happen at run-time, which makes no sense. They expect to run compile-time code when loading a module, module::main_cv, which should be in a BEGIN block or import function.