2011-07-09 71 views
10

我一直在嘗試用Perl 5和XML :: LibXML(我現在維護)來調試內存損壞問題。現在這裏是我得到的:Perl進程被卡住了*** *** glibc檢測到*** perl:損壞的雙向鏈表:0x0000000001474b40 ***» - 我該如何終止?

[email protected]:~/progs/perl/cpan/XML/LibXML/bugs/perl-xml-libxml-bugs/XML-LibXML-reader-segfault$ make test 
XML_CATALOG_FILES="`pwd`/sgml-lib/catalog.xml" perl find_ascii_quotes.pl index.html 
*** glibc detected *** perl: corrupted double-linked list: 0x0000000001474b40 *** 
^Cmake: *** [test] Interrupt 

然後Perl進程卡住,不會返回到shell。事情是,Perl進程停止的事實打斷了我的流程,並且我正在尋找一種讓進程崩潰或者其他任何方式而不是掛在那裏的方式。 GDB報告下面的內容。可以在its Mercurial repository中找到有問題的代碼(只需運行「make test」),然後在x86-64上進行Mandriva Linux開發(Cooker)。

ader-segfault$ gdb --command=cmds.gdb /usr/bin/perl 
GNU gdb (GDB) 7.1-5 (Mandriva Linux release 2011.0) 
Copyright (C) 2010 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "x86_64-mandriva-linux-gnu". 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>... 
Reading symbols from /usr/bin/perl... 
warning: the debug information found in "/usr/lib/debug//usr/bin/perl5.12.3.debug" does not match "/usr/bin/perl" (CRC mismatch). 


warning: the debug information found in "/usr/lib/debug/usr/bin/perl5.12.3.debug" does not match "/usr/bin/perl" (CRC mismatch). 

(no debugging symbols found)...done. 
warning: the debug information found in "/usr/lib/debug//usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so" (CRC mismatch). 

[Thread debugging using libthread_db enabled] 
warning: the debug information found in "/usr/lib/debug//usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Encode/Encode.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Encode/Encode.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Encode/Encode.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Encode/Encode.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug//usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Data/Dumper/Dumper.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Data/Dumper/Dumper.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Data/Dumper/Dumper.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/Data/Dumper/Dumper.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug//usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/IO/IO.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/IO/IO.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/IO/IO.so.debug" does not match "/usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/IO/IO.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug//usr/lib/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/XML/LibXML/LibXML.so.debug" does not match "/usr/lib/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/XML/LibXML/LibXML.so" (CRC mismatch). 

warning: the debug information found in "/usr/lib/debug/usr/lib/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/XML/LibXML/LibXML.so.debug" does not match "/usr/lib/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/XML/LibXML/LibXML.so" (CRC mismatch). 

*** glibc detected *** /usr/bin/perl: corrupted double-linked list: 0x0000000000b83440 *** 
^C 
Program received signal SIGINT, Interrupt. 
0x00007ffff6abe12e in __lll_lock_wait_private() from /lib64/libc.so.6 
Missing debug package(s), you should install: perl-debug-5.12.3-8.x86_64 
(gdb) bt 
#0 0x00007ffff6abe12e in __lll_lock_wait_private() from /lib64/libc.so.6 
#1 0x00007ffff6a4f7a1 in _L_lock_9854() from /lib64/libc.so.6 
#2 0x00007ffff6a4d6eb in malloc() from /lib64/libc.so.6 
#3 0x00007ffff6a43d6d in __libc_message() from /lib64/libc.so.6 
#4 0x00007ffff6a49bfa in malloc_printerr() from /lib64/libc.so.6 
#5 0x00007ffff6a49f38 in malloc_consolidate.part.3() from /lib64/libc.so.6 
#6 0x00007ffff6a4a749 in _int_free() from /lib64/libc.so.6 
#7 0x00007ffff4e8b0e0 in xmlHashFree__internal_alias (table=0xb2db40, 
    f=0x7ffff4e98e00 <xmlFreeAttribute>) at hash.c:324 
#8 0x00007ffff4e82e42 in xmlFreeDtd__internal_alias (cur=0x633310) 
    at tree.c:1126 
#9 0x00007ffff4e8259a in xmlFreeDoc__internal_alias (cur=0x635100) 
    at tree.c:1227 
#10 0x00007ffff51e75a5 in PmmREFCNT_dec() 
    from /usr/lib/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/XML/LibXML/LibXML.so 
#11 0x00007ffff51c4f65 in XS_XML__LibXML__Node_DESTROY() 
    from /usr/lib/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/XML/LibXML/LibXML.so 
#12 0x00007ffff7b1d60d in Perl_pp_entersub() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#13 0x00007ffff7ab9242 in Perl_call_sv() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
---Type <return> to continue, or q <return> to quit--- 
#14 0x00007ffff7b22cfa in Perl_sv_clear() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#15 0x00007ffff7b23552 in Perl_sv_free2() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#16 0x00007ffff7b2314d in Perl_sv_clear() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#17 0x00007ffff7b23552 in Perl_sv_free2() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#18 0x00007ffff51a6ad9 in XS_XML__LibXML__Reader__DESTROY() 
    from /usr/lib/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/XML/LibXML/LibXML.so 
#19 0x00007ffff7b1d60d in Perl_pp_entersub() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#20 0x00007ffff7b14d70 in Perl_runops_standard() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#21 0x00007ffff7ab9083 in Perl_call_sv() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#22 0x00007ffff7b22cfa in Perl_sv_clear() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#23 0x00007ffff7b23552 in Perl_sv_free2() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#24 0x00007ffff7b4a45f in Perl_leave_scope() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
---Type <return> to continue, or q <return> to quit--- 
#25 0x00007ffff7b15ad2 in Perl_pp_unstack() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#26 0x00007ffff7b14d70 in Perl_runops_standard() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#27 0x00007ffff7abed6e in perl_run() 
    from /usr/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so 
#28 0x0000000000400e29 in main() 
(gdb) 
+1

看到最初爲SO提出的模式後面的問題令人耳目一新:一個棘手的技術問題。 – Axeman

+0

最近你有沒有升級到Ubuntu Natty?我已經看到過幾次相同的錯誤 - 不是Perl,而是其他的東西 - 因爲我做了那個 –

+0

@morungos:OP說Mandriva。無論如何,這似乎影響了不少發行人。 Arch Linux上有類似的問題。 – musiKk

回答

9

您可以使用MALLOC_CHECK_環境變量來控制glibc內存檢查的行爲。如果您將其設置爲'3',那麼它將在任何檢測到的錯誤上打印消息和abort()

見的glibc的heap consistency checking文檔信息 - 這實際上可以幫助你調試誤差使MALLOC_CHECK_將執行一致性檢查往往比它在默認情況下(並因此捕獲錯誤越快)。

您可能還想查看Valgrind(如果您還沒有)協助查找您的腐敗問題。

+0

謝謝! MALLOC_CHECK_效果非常好。我之前嘗試過,但拼寫它「_MALLOC_CHECK」,所以它沒有正常工作。 –

5

你的堆被損壞。腐敗幾乎肯定會發生在早些時候 - 可能是更早 - 因爲您正在寫入內存中,您沒有正確分配(例如,寫入超過malloc'd塊的末尾)。

您可以嘗試設置MALLOC_CHECK_ environment variable以更快地檢測到問題,但老實說,您最好的選擇是使用Purify或valgrind這類工具來捕獲發生錯誤的內存訪問。