develooper Front page | perl.perl5.porters | Postings from March 2000

some reports on byteloaded modules

From:
Tom Christiansen
Date:
March 30, 2000 18:31
Subject:
some reports on byteloaded modules
Message ID:
15244.954469888@chthon
You can kind create byteloaded modules and use them like
regular ones.

Can we compile it?

    % perlcc -b -o /tmp/Carp.pm `perl -MCarp -le 'print $INC{"Carp.pm"}'`
    [random noises deleted]
    [Exit 0]

That would be a yes.  Can we uncompile it?

    % perl -MO=Deparse /tmp/Carp.pm
    /tmp/Carp.pm syntax OK
    % perl -MO=Deparse,-p /tmp/Carp.pm
    /tmp/Carp.pm syntax OK

Well, yes and no.  We can uncompile other things.  This one
seems unwillling, however.

May we run it?

    % perl /tmp/Carp.pm
    [Exit 0]

Yes, we can!  Can we do anything cool with it?

    % perl -e 'require "/tmp/Carp.pm"; Carp::carp("wow")'
    wow at -e line 1
	    require /tmp/Carp.pm called at -e line 1
    Not a CODE reference at -e line 1.
    perl in free(): warning: chunk is already free.
    Segmentation fault
    Exit 139

That depends on whether freeing chunks, or blowing them, is cool. :-)

For the curious, here's a backtrace of that incident:

    Starting program: /usr/local/bin/perlD -MCarp -e 'require "/tmp/Carp.pm"; Carp::confess("wow")'
    wow at -e line 1
	    require /tmp/Carp.pm called at -e line 1
    Compilation failed in require at -e line 1.
    perlD in free(): warning: chunk is already free.
    perlD in free(): warning: chunk is already free.

    Program received signal SIGSEGV, Segmentation fault.
    0x2ea58 in Perl_pad_free (po=1069056) at op.c:551
    551             SvPADTMP_off(PL_curpad[po]);
    (gdb) bt
    #0  0x2ea58 in Perl_pad_free (po=1069056) at op.c:551
    #1  0x2eef1 in S_op_clear (o=0x103060) at op.c:833
    #2  0x2ed15 in Perl_op_free (o=0x103060) at op.c:732
    #3  0x2ecba in Perl_op_free (o=0x1032c0) at op.c:720
    #4  0x2ecba in Perl_op_free (o=0x100a00) at op.c:720
    #5  0x339c in perl_destruct (my_perl=0xf5030) at perl.c:396
    #6  0x1792 in main (argc=4, argv=0xdfbfd9ac, env=0xdfbfd9c0) at perlmain.c:55

Hm... can we use/BEGIN it?

    % perl -e 'BEGIN {require "/tmp/Carp.pm"; Carp::->import; } carp "wow"'
    Segmentation fault
    Exit 139

That would be a rather quick no.

What happens if we try to load the other one?

    % perl -e 'require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")'
    Attempt to free unreferenced scalar at /usr/local/lib/perl5/5.6.0/Carp.pm line 99.
    Attempt to free unreferenced scalar at /usr/local/lib/perl5/5.6.0/Carp.pm line 99.
    Attempt to free unreferenced scalar at /usr/local/lib/perl5/5.6.0/Carp.pm line 99.
    Attempt to free unreferenced scalar at /usr/local/lib/perl5/5.6.0/Carp.pm line 99.
    Attempt to free unreferenced scalar at /usr/local/lib/perl5/5.6.0/Carp.pm line 99.
    Attempt to free unreferenced scalar at /usr/local/lib/perl5/5.6.0/Carp.pm line 99.
    Attempt to free unreferenced scalar at /usr/local/lib/perl5/5.6.0/Carp.pm line 99.
    Segmentation fault
    Exit 139

Nope.

For a good time, let's debug it! :-)

    % perl -d -e 'require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")' 
    Default die handler restored.
    Default die handler restored.
    warn set to 0, die set to 0

    Loading DB routines from perl5db.pl version 1.07
    Editor support available.

    Enter h or `h h' for help, or `man perldebug' for more help.

    main::(-e:1):   require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
      DB<1> n
    main::(-e:1): require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
      DB<1> n
    main::(-e:1): require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
      DB<1> n
    main::(-e:1): require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
      DB<1> l
    1==>  require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
      DB<1> n
    wow at -e line 1
	    require /tmp/Carp.pm called at -e line 1
    main::(-e:1):   require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
      DB<1> n
    Signal SEGV: 
    Abort
    Exit 134

And here's the backtrace info on that one:
(gdb) r -d -e 'require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")'
Starting program: /usr/local/bin/perlD -d -e 'require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")'
Default die handler restored.
Default die handler restored.
warn set to 0, die set to 0

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
  DB<1> t
Trace = on
  DB<1> c
main::CODE(0x237d8c)(/tmp/Carp.pm:1):
1:      use ByteLoader 0.03;
ByteLoader::CODE(0x237f00)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/ByteLoader.pm:3):
3:      use XSLoader ();
XSLoader::CODE(0x237f00)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:17):
17:     $VERSION = "0.01";      # avoid typo warning
XSLoader::CODE(0x237f00)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:22):
22:       my $dl_dlext = 'so';
DynaLoader::CODE(0x237f00)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:26):
26:     boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
27:                                     !defined(&dl_load_file);
28:     package XSLoader;
XSLoader::CODE(0x237f00)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:30):
30:     1; # End of main code
ByteLoader::CODE(0x237f00)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/ByteLoader.pm:3):
3:      use XSLoader ();
ByteLoader::CODE(0x237f00)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/ByteLoader.pm:3):

[45 lines deleted]

XSLoader::load(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:80):
80:         if (@unresolved) {
XSLoader::load(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:85):
85:         my $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do {
XSLoader::load(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:90):
90:         my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
XSLoader::load(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:92):
92:         push(@dl_modules, $module); # record loaded module
XSLoader::load(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/XSLoader.pm:95):
95:         return &$xs(@_);
ByteLoader::CODE(0x237d8c)(/usr/local/lib/perl5/5.6.0/OpenBSD.i386-openbsd/ByteLoader.pm:11):
11:     1;
12:     __END__
main::CODE(0x237d8c)(/tmp/Carp.pm:1):
1:      use ByteLoader 0.03;
main::CODE(0x237d8c)(/tmp/Carp.pm:1):
1:      use ByteLoader 0.03;
main::(-e:1):   require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
main::(-e:1):   require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
main::(-e:1):   require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")
Carp::carp(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:253):
253:    1;
Carp::shortmess_heavy(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:162):
162:        goto &longmess_heavy if $Verbose;
Carp::shortmess_heavy(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:163):
163:        return @_ if ref $_[0];
Carp::shortmess_heavy(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:164):
164:        my $error = join '', @_;
Carp::shortmess_heavy(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:165):

[120 lines deleted]

Carp::longmess_heavy(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:125):
125:        my $msg = \($mess || $error);
Carp::longmess_heavy(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:126):
126:        $$msg =~ tr/\0//d;
Carp::longmess_heavy(/usr/local/lib/perl5/5.6.0/Carp/Heavy.pm:127):
127:        $$msg;
wow at -e line 1
        require /tmp/Carp.pm called at -e line 1
main::(-e:1):   require "/tmp/Carp.pm"; require Carp; Carp::carp("wow")

Program received signal SIGSEGV, Segmentation fault.
0xa6c34 in Perl_pp_require () at pp_ctl.c:2899
2899        STRLEN len;
(gdb) bt
#0  0xa6c34 in Perl_pp_require () at pp_ctl.c:2899
#1  0x6521b in Perl_runops_debug () at run.c:56
#2  0x5752 in S_run_body (oldscope=1) at perl.c:1390
#3  0x5382 in perl_run (my_perl=0xf5030) perl.c:1319
#4  0x177f in main (argc=4, argv=0xdfbfd9a4, env=0xdfbfd9b8) at perlmain.c:52


Well, there you have it.  I don't know what it is, but it's all yours. :-)

--tom



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About