/usr/local/bin/perlcc: cms.pl did not compile, which can't happen:

106 views
Skip to first unread message

David Christensen

unread,
Oct 8, 2011, 1:37:22 PM10/8/11
to perl-c...@googlegroups.com
perl-compiler:

I've just installed B::C and am playing with perlcc. When I attempt to
compile a non-trivial CGI script to binary, perlcc fails:

$ perlcc -o foo cms.pl
/usr/local/bin/perlcc: cms.pl did not compile, which can't happen:
warning: IV !IOK sv_list[8270] at /usr/local/lib/perl/5.10.1/B/C.pm
line 1388.
Segmentation fault


When I compile using the bytecode backend:

$ perlcc -B -o bar cms.pl

the output file works and seems faster! :-)


How do I troubleshoot the binary output case?


Are there measurable differences between the binary and the bytecode
outputs?


TIA,

David

$ cat /etc/debian_version
6.0.2

$ perl --version

This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
(with 53 registered patches, see perl -V for more detail)

$ grep 'our..VERSION' `which perlcc`
our $VERSION = 2.12;

rurban

unread,
Oct 8, 2011, 7:25:38 PM10/8/11
to perl-compiler
On Oct 8, 12:37 pm, David Christensen <dpchr...@holgerdanske.com>
wrote:
> perl-compiler:
>
> I've just installed B::C and am playing with perlcc. When I attempt to
> compile a non-trivial CGI script to binary, perlcc fails:
>
>      $ perlcc -o foo cms.pl
>      /usr/local/bin/perlcc: cms.pl did not compile, which can't happen:
>      warning: IV !IOK sv_list[8270] at /usr/local/lib/perl/5.10.1/B/C.pm
> line 1388.
>       Segmentation fault
>
> When I compile using the bytecode backend:
>
>      $ perlcc -B -o bar cms.pl
>
> the output file works and seems faster!  :-)
>
> How do I troubleshoot the binary output case?

That's tricky and certainly not easy.
First use -v6 or -v5 to see the commandline and some verbose output.

If this does not help debug into it.

But IV !IOK sv_list[8270] at /usr/local/lib/perl/5.10.1/B/C.pm line
1388.
is a known bug. It should not happen.
It only happens with very weird code sections, and I don't know yet
if the compiler took a wrong path or its really an unsupported
construct,
such as using Filehandle globs in a certain way.

If the code is free I could debug it.
perl -d -MO=C,-ocms.c cms.pl

But I also got the same problem with recent blead, since the utf8sym4
patch.
Maybe I find the bug in the meantime.
5.10.1 with threads is also not the best perl version around.

> Are there measurable differences between the binary and the bytecode
> outputs?

Yes. B::C compilation produces much faster startup (10-20x faster)
and the runtime is also faster than Bytecode.

David Christensen

unread,
Oct 9, 2011, 1:29:58 AM10/9/11
to perl-c...@googlegroups.com
On 10/08/2011 04:25 PM, rurban wrote:
> First use -v6 or -v5 to see the commandline and some verbose output.

Thank you for your help. :-)


$ perlcc -v6 -o foo cms.pl 2>&1 | wc
59260 301847 2705114

OMG I'll pass for now.


> If the code is free I could debug it.

I added the GPL and boiled down my code (tarball attached):

1. A module Dpchrist::Core.

2. A Perl script perlcc-bug.t

3. A shell script to light it off EXERCISE_BUG.sh


It has something to do with what remains:

1. Dpchrist::Core -- moving or renaming the package changes the error
message.

2. use Log::Log4perl qw( :easy ) -- eliminating or not using in easy
mode changes the error message.

3. require Exporter, @ISA, %EXPORT_TAGS, @EXPORT_OK -- eliminating or
modifying anything, or defining a subroutine "CATEGORY", changes the
error message.

4. use constant FOO => qr/::/ -- eliminating or not using a regex value
changes the error message.


So, there's potential for some complex interactions left in there.


Here's a sample run:

2011-10-08 22:11:56 dpchrist@p43400e ~/sandbox/perl/perlcc-bug
$ ./EXERCISE_BUG.sh
perlcc -o foo perlcc-bug.t
/usr/local/bin/perlcc: perlcc-bug.t did not compile, which can't
happen:
warning: IV !IOK sv_list[25] at /usr/local/lib/perl/5.10.1/B/C.pm
line 1388.
Segmentation fault


I noticed the sv_list[] index getting smaller as I threw code out. I
assume that's a stack? 25 deep is better than 8270! -v6 is much
smaller, but still big:

$ perlcc -v6 -o foo perlcc-bug.t 2>&1 | wc
2284 11416 102162


Good luck debugging it. Let met know if I can do anything. :-)


David

2011-10-08 22:13:50 dpchrist@p43400e ~/sandbox/perl/perlcc-bug
$ perl -MLog::Log4perl -e 'print $Log::Log4perl::VERSION, "\n"'
1.33

2011-10-08 22:18:09 dpchrist@p43400e ~/sandbox/perl/perlcc-bug
$ perl -MExporter -e 'print $Exporter::VERSION, "\n"'
5.63

perlcc-bug.tar.gz
Reply all
Reply to author
Forward
0 new messages