我正在运行一个抓取工具,它从数百个网页中获取一些关键信息。一切正常,但在超时时我遇到了分段错误。
use Perl::Unsafe::Signals;
require LWPx::ParanoidAgent;
...
$ua = LWPx::ParanoidAgent->new();
$ua->timeout(60);
...
local $SIG{ALRM} = sub {
print "Timeout occurred. Skipping to next record.\n";
};
alarm 60; # give each journal a minute to respond, in total.
UNSAFE_SIGNALS {
...
# some calls like the following:
my $pageResponse = $ua->get($url);
if ($pageResponse->is_success) {
# calls to a sub
# that also does $ua->get()
# I think it fails inside the sub (if that makes a diff)
}
};
alarm 0; # clear the timeout.
运行:为 i686-linux 构建的 perl 5,版本 16,subversion 3 (v5.16.3)
该脚本在超时后引发分段错误。我得到“超时发生”的打印,然后是分段错误。
有人对可能发生的事情有任何线索吗?调试建议?
额外信息:我只有一个“eval”块,而不是之前的 UNSAFE_SIGNALS 块,它只会在发生超时时挂起。