我正在使用perl cgi脚本,它使用我们自己的库,它们使用“no autovivification”pragma.例如.
/usr/lib/company/mysim.cgi:
#!/usr/bin/perl -w
use strict;
# ... other use
use Company::Module1;
/usr/lib/perl5/Company/Module1.pm
package Company::Module1;
no autovivification;
use strict;
use warnings;
大约50%的时间,当访问URL到达cgi脚本时,编译失败了……
[Fri Dec 04 15:40:10.744901 2015] [:error] [pid 30455:tid 2961136448] Bareword "A_HINT_STRICT" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_WARN" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_FETCH" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_STORE" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_EXISTS" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nBareword "A_HINT_DELETE" not allowed while "strict subs" in use at /usr/lib/i386-linux-gnu/perl5/5.20/autovivification.pm line 144.\nCompilation failed in require at /usr/lib/company/mysim.cgi line 14.\nBEGIN failed--compilation aborted at /usr/lib/company/mysim.cgi line 14.\n
(取自/var/log/apache2/ssl/error.log,因为此脚本位于https端口).
我的环境是:
– debian jessie(8.2)
– tomcat7
– apache2(2.4)
– perl 5.20.2
– libautovivification-perl 0.12-1 b1
我的问题是:
>有没有人见过这个?由于“use strict”pragma,自动生成模块无法编译,这似乎很奇怪.
>任何人都可以解释编译错误的间歇性吗?更奇怪的是,cgi无法编译〜一半的时间,并且工作正常(即运行并返回预期结果)另一半.
谢谢你的时间.
2015年9月12日:一些其他信息……
谢谢大家的反馈.
没有明确的线程创建,虽然这是在apache的上下文中,所以可能是线程请求.
根本原因似乎是XSLoader中的失败.至少这个最小的工作实例……
package autovivification;
use 5.008_003;
use strict;
use warnings;
our $VERSION;
BEGIN {
$VERSION = '0.12';
}
BEGIN {
require XSLoader;
XSLoader::load(__PACKAGE__, $VERSION);
}
my %bits = (
strict => A_HINT_STRICT,
warn => A_HINT_WARN,
fetch => A_HINT_FETCH,
store => A_HINT_STORE,
exists => A_HINT_EXISTS,
delete => A_HINT_DELETE,
);
编译,而这
package autovivification;
use 5.008_003;
use strict;
use warnings;
our $VERSION;
BEGIN {
$VERSION = '0.12';
}
#BEGIN {
# require XSLoader;
# XSLoader::load(__PACKAGE__, $VERSION);
#}
my %bits = (
strict => A_HINT_STRICT,
warn => A_HINT_WARN,
fetch => A_HINT_FETCH,
store => A_HINT_STORE,
exists => A_HINT_EXISTS,
delete => A_HINT_DELETE,
);
失败并出现同样的错误.
所以,我会去寻找apache日志中的加载错误……某处.
感谢你的宝贵时间.
2015年12月16日:更新 – 修正
根本原因是mod_perl,结合了apache 2.2和2.4之间的(可能的)变化.在设置要由mod_perl处理的URI / cgi-bin之前,脚本的apache配置(为其提供/ cgi-bin / script的ScriptAlias URI)发生.在apache 2.2中,这种排序似乎很重要,并且mod_perl不处理脚本.但是,在apache 2.4中,排序似乎并不重要,脚本现在由mod_perl处理.
出现错误是因为这个脚本不是(并且从未打算)由mod_perl处理.解决方法是将脚本的URI更改为/ somethingelse / script.
感谢大家的评论.
最佳答案 根本原因是mod_perl,结合了apache 2.2和2.4之间的(可能的)变化.在设置要由mod_perl处理的URI / cgi-bin之前,脚本的apache配置(为其提供/ cgi-bin / script的ScriptAlias URI)发生.在apache 2.2中,这种排序似乎很重要,并且mod_perl不处理脚本.但是,在apache 2.4中,排序似乎并不重要,脚本现在由mod_perl处理.
出现错误是因为这个脚本不是(并且从未打算)由mod_perl处理.解决方法是将脚本的URI更改为/ somethingelse / script.
– HalfOpenedEye