0

我在我的 Ubuntu 10.04 机器上安装了 ActivePerl 5.10.1.1007。我有一个非常简单的 Perl 脚本,其中包含以下几行:

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

my $Interpreter = new Tcl;

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

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

输出如下:

$ /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

请帮忙。我找不到使这项工作的方法。设置非环境变量不会导致崩溃。例如:

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

谢谢!!!

4

3 回答 3

1

第一阶段分析:退出时内存损坏。我想说,关于谁应该释放块以及如何释放块存在交战。现在我们深入挖掘……</p>

可能会看到 Perl 和 Tcl 都在独立尝试解决错误环境变量的系统实现中的错误功能。特别是,C 库存setenv()在许多内存泄漏问题,这使得它比您可能天真的期望的更不切实际;我非常希望 Perl 能够解决这个问题,而且我知道Tcl 也可以,但这确实意味着只有一种语言应该设置环境变量,并且在这种情况下几乎肯定需要是 Perl(根据你的证据'已经提出)。

你真的需要从你的 Tcl 代码中设置环境变量吗?如果你不能这样做,那将是最简单的方法。:-) 否则,我们谈论的是构建不同的 Tcl(以便它要求 Perl 端进行内存管理)或做一些魔术来断开 Tcl 端与真实环境的连接。您可能还想将问题上游报告给 ActiveState。

于 2010-06-26T20:44:52.570 回答
1

我会继续挖掘,如果我找到解决方案,我会告诉你的。我将此报告给 ActiveState。内联是我的电子邮件和他们的回复,但总结一下:

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.
于 2010-06-28T08:38:53.283 回答
0

你不应该需要这条线:use lib "/opt/ActivePerl-5.10/lib"; 除非你有一个错误的配置。您可能想从轨道上取消安装并重新开始。

您使用 ActivePerl 有什么特别的原因吗?您应该能够简单地从源代码安装 perl - 您使用的是真正的操作系统,所以我会利用它:)

于 2010-06-25T16:21:50.540 回答