启用信号处理程序时,我得到一个段错误.
为了支持,我删除了所有的curses代码以解决问题.
码:
#!/usr/bin/env perluse strict;use warnings;use threads;sub cleanup { exit 0; }sub run { while (1) {} }# comment this line and the problem disappears$SIG{INT} = \&cleanup;foreach my $i (1..100) { print "Creating this thread\n"; my $t = threads->create(\&run); print "Created that thread\n";}while (1) { print "LooPing\n"; }
示例错误跟踪(90%的时间段为segfaults):
$./threadtest.perl...Creating this threadCreating that threadDetaching this threadDetaching that threadCreating this thread^CSegmentation fault$
眼镜:
>线程1.72
> archname“”
> os“”
> Perl 5.10.1(Debian附带)Debian
> 6挤压
初步印象:
我认为当自定义信号处理程序获取控制权时会出现问题.这会以某种方式阻止创建下一个线程,从而导致段错误.
Perl的默认SIGINT处理程序是否运行特殊代码以安全地结束线程创建的评估?如果是这样,我想解决方案是将copypasta引入自定义处理程序.
解决方法 revision history for thethreads
module包含: 1.73 Mon Jun 8 13:17:04 2009- Signal handling during thread creation/destruction (John Wright)- Upgraded ppport.h to Devel::PPPort 3.17
这表明在早于1.73的版本中,在创建和销毁线程期间存在已知的信号处理问题.升级您的线程模块.
总结以上是内存溢出为你收集整理的linux – 为什么我的线程Perl脚本会出现段错误?全部内容,希望文章能够帮你解决linux – 为什么我的线程Perl脚本会出现段错误?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)