views:

54

answers:

3

I installed ActivePerl 5.10.1.1007 on my Ubuntu 10.04 machine. I have a very simple Perl script with the following lines:

use lib "/opt/ActivePerl-5.10/lib";
use Tcl;

my $Interpreter = new Tcl;

$Interpreter->Eval('puts "Hello world"');

$Interpreter->Eval('set ::env(TESTVAR) 55')

The output is the following:

$ /opt/ActivePerl-5.10/bin/perl5.10.1 simple.pl
Hello world
*** glibc detected *** /opt/ActivePerl-5.10/bin/perl5.10.1: munmap_chunk(): invalid pointer: 0x09b5e0d8 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0xb7696591]
/lib/tls/i686/cmov/libc.so.6(+0x6c80e)[0xb769780e]
/opt/ActivePerl-5.10/bin/perl5.10.1(perl_destruct+0xda6)[0x8071716]
/opt/ActivePerl-5.10/bin/perl5.10.1(main+0xb0)[0x8060a30]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb7641bd6]
/opt/ActivePerl-5.10/bin/perl5.10.1(chroot+0x31)[0x80608e1]
======= Memory map: ========
08048000-0815e000 r-xp 00000000 08:11 5154055    /opt/ActivePerl-5.10/bin/perl-static
0815e000-08160000 rwxp 00116000 08:11 5154055    /opt/ActivePerl-5.10/bin/perl-static
09aae000-09bf1000 rwxp 00000000 00:00 0          [heap]
b6ad8000-b6af5000 r-xp 00000000 08:11 3399754    /lib/libgcc_s.so.1
b6af5000-b6af6000 r-xp 0001c000 08:11 3399754    /lib/libgcc_s.so.1
b6af6000-b6af7000 rwxp 0001d000 08:11 3399754    /lib/libgcc_s.so.1
b6af7000-b6b01000 r-xp 00000000 08:11 3424653    /lib/tls/i686/cmov/libnss_files-2.11.1.so
b6b01000-b6b02000 r-xp 00009000 08:11 3424653    /lib/tls/i686/cmov/libnss_files-2.11.1.so
b6b02000-b6b03000 rwxp 0000a000 08:11 3424653    /lib/tls/i686/cmov/libnss_files-2.11.1.so
b6b03000-b6b0b000 r-xp 00000000 08:11 3424655    /lib/tls/i686/cmov/libnss_nis-2.11.1.so
b6b0b000-b6b0c000 r-xp 00007000 08:11 3424655    /lib/tls/i686/cmov/libnss_nis-2.11.1.so
b6b0c000-b6b0d000 rwxp 00008000 08:11 3424655    /lib/tls/i686/cmov/libnss_nis-2.11.1.so
b6b0d000-b6b13000 r-xp 00000000 08:11 3424651    /lib/tls/i686/cmov/libnss_compat-2.11.1.so
b6b13000-b6b14000 r-xp 00006000 08:11 3424651    /lib/tls/i686/cmov/libnss_compat-2.11.1.so
b6b14000-b6b15000 rwxp 00007000 08:11 3424651    /lib/tls/i686/cmov/libnss_compat-2.11.1.so
b6b2a000-b6b2b000 ---p 00000000 00:00 0 
b6b2b000-b732b000 rwxp 00000000 00:00 0 
b74c1000-b74cb000 r-xp 00000000 08:11 5162486    /opt/ActivePerl-5.10/lib/auto/Tcl/Tcl.so
b74cb000-b74cc000 rwxp 00009000 08:11 5162486    /opt/ActivePerl-5.10/lib/auto/Tcl/Tcl.so
b74cc000-b750b000 r-xp 00000000 08:11 5712734    /usr/lib/locale/en_US.utf8/LC_CTYPE
b750b000-b7629000 r-xp 00000000 08:11 5712735    /usr/lib/locale/en_US.utf8/LC_COLLATE
b7629000-b762b000 rwxp 00000000 00:00 0 
b762b000-b777e000 r-xp 00000000 08:11 3424483    /lib/tls/i686/cmov/libc-2.11.1.so
b777e000-b777f000 ---p 00153000 08:11 3424483    /lib/tls/i686/cmov/libc-2.11.1.so
b777f000-b7781000 r-xp 00153000 08:11 3424483    /lib/tls/i686/cmov/libc-2.11.1.so
b7781000-b7782000 rwxp 00155000 08:11 3424483    /lib/tls/i686/cmov/libc-2.11.1.so
b7782000-b7785000 rwxp 00000000 00:00 0 
b7785000-b779a000 r-xp 00000000 08:11 3424658    /lib/tls/i686/cmov/libpthread-2.11.1.so
b779a000-b779b000 r-xp 00014000 08:11 3424658    /lib/tls/i686/cmov/libpthread-2.11.1.so
b779b000-b779c000 rwxp 00015000 08:11 3424658    /lib/tls/i686/cmov/libpthread-2.11.1.so
b779c000-b779e000 rwxp 00000000 00:00 0 
b779e000-b77a0000 r-xp 00000000 08:11 3424663    /lib/tls/i686/cmov/libutil-2.11.1.so
b77a0000-b77a1000 r-xp 00001000 08:11 3424663    /lib/tls/i686/cmov/libutil-2.11.1.so
b77a1000-b77a2000 rwxp 00002000 08:11 3424663    /lib/tls/i686/cmov/libutil-2.11.1.so
b77a2000-b77ab000 r-xp 00000000 08:11 3424646    /lib/tls/i686/cmov/libcrypt-2.11.1.so
b77ab000-b77ac000 r-xp 00008000 08:11 3424646    /lib/tls/i686/cmov/libcrypt-2.11.1.so
b77ac000-b77ad000 rwxp 00009000 08:11 3424646    /lib/tls/i686/cmov/libcrypt-2.11.1.so
b77ad000-b77d4000 rwxp 00000000 00:00 0 
b77d4000-b77f8000 r-xp 00000000 08:11 3424648    /lib/tls/i686/cmov/libm-2.11.1.so
b77f8000-b77f9000 r-xp 00023000 08:11 3424648    /lib/tls/i686/cmov/libm-2.11.1.so
b77f9000-b77fa000 rwxp 00024000 08:11 3424648    /lib/tls/i686/cmov/libm-2.11.1.so
b77fa000-b77fb000 rwxp 00000000 00:00 0 
b77fb000-b77fd000 r-xp 00000000 08:11 3424647    /lib/tls/i686/cmov/libdl-2.11.1.so
b77fd000-b77fe000 r-xp 00001000 08:11 3424647    /lib/tls/i686/cmov/libdl-2.11.1.so
b77fe000-b77ff000 rwxp 00002000 08:11 3424647    /lib/tls/i686/cmov/libdl-2.11.1.so
b77ff000-b7812000 r-xp 00000000 08:11 3424650    /lib/tls/i686/cmov/libnsl-2.11.1.so
b7812000-b7813000 r-xp 00012000 08:11 3424650    /lib/tls/i686/cmov/libnsl-2.11.1.so
b7813000-b7814000 rwxp 00013000 08:11 3424650    /lib/tls/i686/cmov/libnsl-2.11.1.so
b7814000-b7816000 rwxp 00000000 00:00 0 
b781a000-b781b000 r-xp 00000000 08:11 1859586    /usr/lib/locale/en_US.utf8/LC_NUMERIC
b781b000-b781c000 r-xp 00000000 08:11 5712754    /usr/lib/locale/en_US.utf8/LC_TIME
b781c000-b781d000 r-xp 00000000 08:11 5712755    /usr/lib/locale/en_US.utf8/LC_MONETARY
b781d000-b781e000 r-xp 00000000 08:11 5712756    /usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES
b781e000-b781f000 r-xp 00000000 08:11 1859591    /usr/lib/locale/en_US.utf8/LC_PAPER
b781f000-b7820000 r-xp 00000000 08:11 1859592    /usr/lib/locale/en_US.utf8/LC_NAME
b7820000-b7821000 r-xp 00000000 08:11 5712757    /usr/lib/locale/en_US.utf8/LC_ADDRESS
b7821000-b7822000 r-xp 00000000 08:11 5712758    /usr/lib/locale/en_US.utf8/LC_TELEPHONE
b7822000-b7823000 r-xp 00000000 08:11 1859595    /usr/lib/locale/en_US.utf8/LC_MEASUREMENT
b7823000-b782a000 r-xs 00000000 08:11 5711192    /usr/lib/gconv/gconv-modules.cache
b782a000-b782b000 r-xp 00000000 08:11 5712759    /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION
b782b000-b782d000 rwxp 00000000 00:00 0 
b782d000-b782e000 r-xp 00000000 00:00 0          [vdso]
b782e000-b7849000 r-xp 00000000 08:11 3401485    /lib/ld-2.11.1.so
b7849000-b784a000 r-xp 0001a000 08:11 3401485    /lib/ld-2.11.1.so
b784a000-b784b000 rwxp 0001b000 08:11 3401485    /lib/ld-2.11.1.so
bfd36000-bfd4b000 rwxp 00000000 00:00 0          [stack]
Aborted

Please help. I can't find a way to make this work. Setting a non-environment variable does not cause the crash. For example:

 $Interpreter->Eval('set localvar 55')

THANKS!!!

A: 

You should not need this line: use lib "/opt/ActivePerl-5.10/lib"; unless you have a misconfiguration. You might want to nuke the install from orbit and start over.

Is there any particular reason why you are using ActivePerl? You should be able to simply install perl from source -- you're using a real OS, so I'd take advantage of it :)

Ether
A: 

First stage analysis: memory corruption on exit. I'd say that there's warring over who should free a block and how. Now we dig deeper…

It's possible that you're seeing the consequences of the fact that both Perl and Tcl are independently trying to work around the bugs misfeatures in the system implementation of environment variables. In particular, the C library's setenv() has a number of problems with memory leaks which make it rather more impractical than you might naïvely expect; I'd quite expect Perl to work around this, and I know that Tcl does too, but it does mean that only one language should set environment variables, and that almost certainly needs to be Perl in this case (on the basis of evidence you've presented).

Do you really need to set environment variables from your Tcl code? If you can just not do it, that'd be the easiest way forward. :-) Otherwise, we're talking about having a different build of Tcl (so that it asks the Perl side of things to do the memory management) or doing some magic to disconnect the Tcl side from the real environment. You might also want to report the problem upstream to ActiveState.

Donal Fellows
A: 

I'll keep digging and if I find the solution I'll let you know. I reported this to ActiveState. Inline is my email and their response, but to sum up:

1. They didn't develop "Inline Tcl" for Perl nor did they test it.
2. It was developed in 2001 and no additions were made to it since then.
3. When it was developed (in 2001), it was marked as "alpha" and no additions were made since then.



Hi Mircea,

Inline::Tcl is not part of ActivePerl. It's not tested with ActivePerl, and it
does not build on our PPM build farm against ActivePerl:
http://ppm4.activestate.com/i686-linux/5.10/1000/R/RR/RRS/Inline-Tcl-0.09.d/log-20090614T112213.txt

Offhand, the error message looks like a compiler mismatch problem, but it could be
almost anything since Inline::Tcl hasn't been touched by the author since 2001,
and even then the release notes describe it as "alpha software". It doesn't seem
to like Linux very much any more:
http://matrix.cpantesters.org/?dist=Inline-Tcl%200.09;maxver=1
Hmm.. The author's home page is 404. You should probably find another way to do it.
Mircea