glibc在RHEL 5中损坏了双链表

时间:2014-02-21 19:25:55

标签: c++ linux rhel5

我有一个用C ++编写的代码,它生成一个sharedlib(.so)文件,该文件又用于我在RHEL3上运行的应用程序。

现在我必须迁移到RHEL5。 .so文件的代码编译成功,但是当我尝试启动我的服务时,它显示 ** glibc损坏的双链表 ** ,但服务启动成功。< / p>

这可能是因为操作系统与RHEL3中编译的相同代码相同。

另外,如果我将RHEL3中编译的.so文件复制到RHEL5机器,一切正常。

    This is what i got by running valgrind :
==19845== Invalid read of size 4
==19845==    at 0x453F4EC: std::_Rb_tree<int, std::pair<int const, key>, std::_Select1st<std::pair<int const, key> >, std::less<int>, std::allocator<std::pair<int const, key> > >::_S_right(std::_Rb_tree_node_base*) (in /home/test/examplesofile1.so)
==19845==    by 0x45408AA: std::_Rb_tree<int, std::pair<int const, key>, std::_Select1st<std::pair<int const, key> >, std::less<int>, std::allocator<std::pair<int const, key> > >::_M_erase(std::_Rb_tree_node<std::pair<int const, key> >*) (in /home/test/examplesofile1.so)
==19845==    by 0x4540918: std::_Rb_tree<int, std::pair<int const, key>, std::_Select1st<std::pair<int const, key> >, std::less<int>, std::allocator<std::pair<int const, key> > >::~_Rb_tree() (in /home/test/examplesofile1.so)
==19845==    by 0x4540974: std::map<int, key, std::less<int>, std::allocator<std::pair<int const, key> > >::~map() (in /home/test/examplesofile1.so)
==19845==    by 0x48235FB: (within /home/test/examplesofile2.so)
==19845==    by 0xAA5058: __cxa_finalize (in /lib/libc-2.5.so)
==19845==    by 0x477BC03: (within /home/test/examplesofile2.so)
==19845==    by 0x4A2FDEB: (within /home/test/examplesofile2.so)
==19845==    by 0xA697CD: _dl_fini (in /lib/ld-2.5.so)
==19845==    by 0xAA4DA8: exit (in /lib/libc-2.5.so)
==19845==    by 0x8086F57: vMakeDaemon (commonfunctions.c:438)
==19845==    by 0x8067F9A: Initialize (mngr.c:360)

1 个答案:

答案 0 :(得分:1)

在大多数情况下,这意味着一些内存被释放两次。 所以这个bug很可能出现在你的代码中。

尝试在新系统上重新编译库,并使用valgrind查找导致问题的原因。