【问题标题】:Debug Perl Segmentation Fault调试 Perl 分段错误
【发布时间】:2013-02-10 15:08:18
【问题描述】:

我正在使用AcePerl 从 wormbase.org 数据库下载数据。 当我下载某些数据库对象时(在一定数量的对象之后)出现分段错误。这种行为是可重现的。

我查看了核心转储,where 打印了一大堆函数调用:

#0  0xb763c0ac in ?? () from /lib/i386-linux-gnu/libc.so.6
#1  0xb763eddc in malloc () from /lib/i386-linux-gnu/libc.so.6
#2  0x080c07ca in Perl_safesysmalloc ()
#3  0x080f3a02 in Perl_sv_grow ()
#4  0x080ebe38 in Perl_sv_setsv_flags ()
#5  0x080ecb76 in Perl_newSVsv ()
#6  0x0811516f in Perl_save_item ()
#7  0x080c7dd8 in Perl_get_db_sub ()
#8  0x080e7a4c in Perl_pp_entersub ()
#9  0x08075570 in Perl_call_sv ()
#10 0x080edd25 in Perl_sv_clear ()
#11 0x080ee3eb in Perl_sv_free2 ()
#12 0x080d79ec in Perl_hv_free_ent ()
#13 0x080d7c8c in ?? ()
#14 0x080db6ff in Perl_hv_undef_flags ()
#15 0x080edf72 in Perl_sv_clear ()
#16 0x080ee3eb in Perl_sv_free2 ()
#17 0x080d79ec in Perl_hv_free_ent ()
#18 0x080d7c8c in ?? ()
#19 0x080db6ff in Perl_hv_undef_flags ()
#20 0x080edf72 in Perl_sv_clear ()
#21 0x080ee3eb in Perl_sv_free2 ()
#22 0x080d79ec in Perl_hv_free_ent ()
#23 0x080d7c8c in ?? ()
#24 0x080db6ff in Perl_hv_undef_flags ()
#25 0x080edf72 in Perl_sv_clear ()
#26 0x080ee3eb in Perl_sv_free2 ()
#27 0x080d79ec in Perl_hv_free_ent ()
#28 0x080d7c8c in ?? ()
#29 0x080db6ff in Perl_hv_undef_flags ()
#30 0x080edf72 in Perl_sv_clear ()
#31 0x080ee3eb in Perl_sv_free2 ()
#32 0x080d79ec in Perl_hv_free_ent ()
#33 0x080d7c8c in ?? ()
#34 0x080db6ff in Perl_hv_undef_flags ()
#35 0x080edf72 in Perl_sv_clear ()
#36 0x080ee3eb in Perl_sv_free2 ()
#37 0x080d79ec in Perl_hv_free_ent ()
#38 0x080d7c8c in ?? ()
#39 0x080db6ff in Perl_hv_undef_flags ()
#40 0x080edf72 in Perl_sv_clear ()
#41 0x080ee3eb in Perl_sv_free2 ()
#42 0x080d79ec in Perl_hv_free_ent ()
#43 0x080d7c8c in ?? ()
#44 0x080db6ff in Perl_hv_undef_flags ()
#45 0x080edf72 in Perl_sv_clear ()
#46 0x080ee3eb in Perl_sv_free2 ()
#47 0x080d79ec in Perl_hv_free_ent ()
#48 0x080d7c8c in ?? ()
#49 0x080db6ff in Perl_hv_undef_flags ()
#50 0x080edf72 in Perl_sv_clear ()
#51 0x080ee3eb in Perl_sv_free2 ()
#52 0x080d79ec in Perl_hv_free_ent ()
#53 0x080d7c8c in ?? ()
...

这些函数调用重复了数千次。 我也调用了perl -d:Trace myscript.pl > log,但日志文件大约有 3 GB 大。

有没有更方便的方法来调试这个脚本?

编辑: 我的脚本:http://paste.ubuntu.com/5564630/ .
我的架构文件:http://paste.ubuntu.com/5564631/。它确定要下载哪些数据。
段错误在 ~2300 go_terms 之后引发。

【问题讨论】:

  • 可能值得看看循环位之前堆栈跟踪中的内容。
  • 您是否尝试过使用最新版本的 Perl?
  • 你能告诉我如何提取这个堆栈跟踪吗?
  • 呃,你已经发布了 53 行了……只是好奇它的另一端是什么。
  • 这不是您脚本中的错误(至少直接如此)。这可能是 Perl 本身的一个错误,这就是我询问 Perl 版本的原因。它也可能是 XS 模块中的错误,您提到的 DB 驱动程序肯定是。

标签: perl debugging segmentation-fault


【解决方案1】:

安装Devel::Trace

在启用跟踪的情况下运行您的 perl 脚本:

perl -d:Trace myscript.pl >trace 2>&1

跟踪文件以查看导致分段错误的 Perl 行的执行情况。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-11
    • 2015-02-18
    • 1970-01-01
    • 1970-01-01
    • 2012-07-06
    • 2023-03-23
    • 1970-01-01
    • 2016-09-07
    相关资源
    最近更新 更多