Subject: | Perl crash if syntax error happens before a sub with Sub::Attribute attribute |
I've encountered a somehow strange problem with Perl 5.10.0 and Sub::Attribute: If any
compile-time error happens in a file with active Sub::Attribute attributes, this might cause a
Perl crash instead of error reporting. This is probably more a perl bug, but it's triggered by
Sub::Attribute.
Here's an example of what I mean:
use warnings;
use strict;
sub my_sub_with_error {
print $foo; # undeclared variable causes use strict to croak
}
sub my_sub_with_attribute : SomeAttribute { }
This will lead to a perl crash (at least on Mac OS X), no matter what the code for
SomeAttribute is - even with a completely empty sub as attribute handler.
It seems this is somehow caused by calling call_sv after an error already happened during the
compilation phase.
A simple:
if( SvTRUEx(ERRSV)) return;
at the beginning of your apply_handler function works around the problem, by the way.
For completeness, the stacktrace follows (no line numbers unfortunately):
0 libperl.dylib 0x000000010009f0ff Perl_die_where + 1112
1 libperl.dylib 0x0000000100054283 Perl_vcroak + 66
2 libperl.dylib 0x00000001000543ce Perl_my_vsnprintf + 0
3 libperl.dylib 0x0000000100034526 Perl_newATTRSUB + 2234
4 libperl.dylib 0x0000000100033613 Perl_utilize + 711
5 libperl.dylib 0x0000000100025f4d Perl_yyparse + 4307
6 libperl.dylib 0x000000010009bb62 Perl_dowantarray + 753
7 libperl.dylib 0x00000001000a2a5c Perl_pp_require + 5193
8 libperl.dylib 0x000000010006e6cc Perl_runops_standard + 42
9 libperl.dylib 0x000000010006956f Perl_call_sv + 897
10 libperl.dylib 0x0000000100069978 Perl_call_list + 538
11 libperl.dylib 0x0000000100028054 Perl_ck_anoncode + 243
12 libperl.dylib 0x00000001000348d9 Perl_newATTRSUB + 3181
13 libperl.dylib 0x0000000100033613 Perl_utilize + 711
14 libperl.dylib 0x0000000100025f4d Perl_yyparse + 4307
15 libperl.dylib 0x000000010009bb62 Perl_dowantarray + 753
16 libperl.dylib 0x00000001000a2a5c Perl_pp_require + 5193
17 libperl.dylib 0x000000010006e6cc Perl_runops_standard + 42
18 libperl.dylib 0x000000010006956f Perl_call_sv + 897
19 libperl.dylib 0x0000000100069978 Perl_call_list + 538
20 libperl.dylib 0x0000000100028054 Perl_ck_anoncode + 243
21 libperl.dylib 0x00000001000348d9 Perl_newATTRSUB + 3181
22 libperl.dylib 0x0000000100033613 Perl_utilize + 711
23 libperl.dylib 0x0000000100025f4d Perl_yyparse + 4307
24 libperl.dylib 0x000000010009bb62 Perl_dowantarray + 753
25 libperl.dylib 0x00000001000a2a5c Perl_pp_require + 5193
26 libperl.dylib 0x000000010006e6cc Perl_runops_standard + 42
27 libperl.dylib 0x000000010006e43a perl_run + 480
28 perl5.10.0 0x0000000100000da4 main + 228
29 perl5.10.0 0x0000000100000cb8 start + 52