簡體   English   中英

程序退出時在__tcf_0處出現分段錯誤

[英]segmentation fault at __tcf_0 when program exits

程序退出時,將給出以下信息:

*** glibc detected *** double free or corruption (!prev): 0x09a8fcb8 ***

似乎對一個對象有雙重釋放。 然后,我使用gdb調試coredump文件。 以下是bt結果(未發布更多跟蹤):

#0 0x005197a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x0055a825 in raise () from /lib/tls/libc.so.6
#2 0x0055c289 in abort () from /lib/tls/libc.so.6
#3 0x0058ecda in __libc_message () from /lib/tls/libc.so.6
#4 0x0059556f in _int_free () from /lib/tls/libc.so.6
#5 0x0059594a in free () from /lib/tls/libc.so.6
#6 0x00c0f001 in operator delete (ptr=0x0) at ../../../../gcc-4.2.2/libstdc++-v3/libsupc++/del_op.cc:49
#7 0x00bea48d in std::string::_Rep::_M_destroy (this=0x9a8fcb8, __a=@0xbfe134af)
  at /home/robert_bu/src/build_gcc-4.2.2/i686-pc-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:97
#8 0x070807e8 in __tcf_0 () from ./../bin/../lib/librlxvm_kmmpv_ocp_tl2.so
#9 0x0055d5a7 in exit () from /lib/tls/libc.so.6
...

然后,valgrind結果顯示該字符串已被兩個不同的.so文件(libkmm.so.2.0.0和libpv.so.2.0.0)刪除。 詳細信息(某些行被屏蔽):

==28125== Invalid free() / delete / delete[]
==28125==    at 0x400588F: operator delete(void*) (vg_replace_malloc.c:387)
==28125==    by 0x446548C: std::string::_Rep::_M_destroy(std::allocator<char> const&) (new_allocator.h:97)
==28125==    by 0x55FA7E7: __tcf_0 (in /home/alan_tao/vm/test/lib/libkmm.so.2.0.0)
==28125==    by 0x55D5A6: exit (in /lib/tls/libc-2.3.4.so)
==28125==    by 0x42B10D9: stop_sim() (in /home/alan_tao/vm/test/lib/libcomm.so.2.0.0)
==28125==    by 0x807C83A: func_on_exit(int) (in /home/alan_tao/vm/test/bin/engine)
==28125==    by 0x55A917: ??? (in /lib/tls/libc-2.3.4.so)
...
==28125==  Address 0x4a484d0 is 0 bytes inside a block of size 525 free'd
==28125==    at 0x400588F: operator delete(void*) (vg_replace_malloc.c:387)
==28125==    by 0x446548C: std::string::_Rep::_M_destroy(std::allocator<char> const&) new_allocator.h:97)
==28125==    by 0x650C0B7: __tcf_0 (in /home/alan_tao/vm/test/lib/libpv.so.2.0.0)
==28125==    by 0x55D5A6: exit (in /lib/tls/libc-2.3.4.so)
==28125==    by 0x42B10D9: stop_sim() (in /home/alan_tao/vm/test/lib/libcomm.so.2.0.0)
==28125==    by 0x807C83A: func_on_exit(int) (in /home/alan_tao/vm/test/bin/engine)
==28125==    by 0x55A917: ??? (in /lib/tls/libc-2.3.4.so)

...


valgrind結果顯示一個字符串被刪除兩次。 但是我不知道正確的靜態方法。 誰知道刪除哪個字符串會導致錯誤以及如何解決該錯誤? 謝謝

PS:程序在Linux 2.6.9下運行。 gcc版本是4.2.2。 使用dll。

新更新:使用gdb列出錯誤的lib文件,命令“ l __tcf_0”顯示以下代碼:

inline std::vector<const char*>& get_phase_name_vec(){
  static std::vector<const char*> phase_name_vec(END_RESP+1, (const char*)NULL);
  return phase_name_vec;
}

這來自OSCI TLM頭文件。 並且上述庫必須包括它們。 它在單獨的命名空間“ tlm”中。 有解決此錯誤的想法嗎?

問題已經解決了。 libkmm.so.2.0.0的源文件和tlm頭文件中存在全局變量名沖突。

似乎“ l __tcf_0”沒有顯示正確的變量。 感謝Alex,maverik,IulianŞerbănoiu和其他閱讀此問題的人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM