C++ 对象超出范围时崩溃-glibc检测到free():std::set中的指针无效

C++ 对象超出范围时崩溃-glibc检测到free():std::set中的指针无效,c++,valgrind,C++,Valgrind,在对大型应用程序的(其他部分)进行了一些更改之后,当输出列表对象超出范围时,我会得到下面的运行时“glibc:double-free或corruption(out)”。我不明白为什么 (如果将声明移动到更高的/外部范围,则当对象超出范围时仍会发生错误。稍后) mExternalInputs=ExitPutList中的“=”不应该将整个列表复制到对象中,让ExitPutList可以被销毁吗?(并且任何地方都没有新增/删除) 我一整天都在做这个,没有主意。我已经把代码拉到了它自己的文件中,它工作得很

在对大型应用程序的(其他部分)进行了一些更改之后,当输出列表对象超出范围时,我会得到下面的运行时“glibc:double-free或corruption(out)”。我不明白为什么

(如果将声明移动到更高的/外部范围,则当对象超出范围时仍会发生错误。稍后)

mExternalInputs=ExitPutList中的“=”不应该将整个列表复制到对象中,让ExitPutList可以被销毁吗?(并且任何地方都没有新增/删除)

我一整天都在做这个,没有主意。我已经把代码拉到了它自己的文件中,它工作得很好;只是不在大系统中。我可以注意什么或进一步调查什么

非常感谢

typedef std::list<TExternalInputs> TExtInputList;

if (1)
{
    TRACE(("%N noOfExtInput: %d\n", noOfExtInput));
    TExtInputList   ExtInputList;
    for (int i = 0; i < noOfExtInput; i++)
    {
        TExternalInputs ExtInput;
        TRACE(("%N Reading external input data\n"));
        bool found = stream.readObject(ExtInput, i);
        TRACE(("%N stream.readObject found=%d\n", found));
        ExtInput.dump();
        ExtInputList.push_back(ExtInput);
    }
    TRACE(("%N pre  mExternalInputs = ExtInputList\n"));
    mExternalInputs = ExtInputList;
    TRACE(("%N post mExternalInputs = ExtInputList\n"));
}  <==== error is here
TRACE(("%N post if() \n"));
运行时错误(为方便起见需要):

DvDbPortConfig::deserialize()
DvCfgStream::read SlotDataDvCfgStream SlotData idx: 0 created
DvCfgStream::read created new node for 'SlotData'. pCfg == 0
DvDbPortConfig.cpp noOfExtInput: 1
DvDbPortConfig.cpp Reading external input data
DvCfgStream::read ExternalInputsDvCfgStream ExternalInputs idx: 0 created
DvCfgStream::read created new node for 'ExternalInputs'. pCfg == 0
DvDbPortConfig.cpp stream.readObject found=1
TExternalInputs slot: 1
  - 'ASI'
DvDbPortConfig.cpp pre  mExternalInputs = ExtInputList
DvDbPortConfig.cpp post mExternalInputs = ExtInputList
*** glibc detected *** ./DvMain: double free or corruption (out): 0x0a2149e8 ***
======= Backtrace: =========/lib/libc.so.6[0x934e31]
/lib/libc.so.6[0x937571]
/usr/lib/libstdc++.so.6(operator delete(void*)+0x22)[0x46465552]
./DvMain(TExternalInputs::~TExternalInputs()+0x28)[0x80503a6]
/usr/local/dvstation/lib/libdvlog.so.6(__gnu_cxx::new_allocator<TExternalInputs>::destroy(TExternalInputs*)+0x18)[0xb756f192]
/usr/local/dvstation/lib/libdvlog.so.6(std::_List_base<TExternalInputs, std::allocator<TExternalInputs> >::_M_clear()+0x56)[0xb756d374]
/usr/local/dvstation/lib/libdvlog.so.6(std::_List_base<TExternalInputs, std::allocator<TExternalInputs> >::~_List_base()+0x1f)[0xb756b595]
/usr/local/dvstation/lib/libdvlog.so.6(std::list<TExternalInputs, std::allocator<TExternalInputs> >::~list()+0x1d)[0xb756abe1]
DvDbPortConfig::反序列化()
DvCfgStream::已创建读取SlotData DvCfgStream SlotData idx:0
DvCfgStream::read为“SlotData”创建了新节点。pCfg==0
DvDbPortConfig.cpp noOfExtInput:1
DvDbPortConfig.cpp读取外部输入数据
DvCfgStream::已创建读取外部输入SDVCFGSTREAM外部输入idx:0
DvCfgStream::read为“ExternalInputs”创建了新节点。pCfg==0
找到DvDbPortConfig.cpp stream.readObject=1
texternalinput插槽:1
-“阿西”
DvDbPortConfig.cpp pre-mExternalInputs=ExitPutList
DvDbPortConfig.cpp post mExternalInputs=EXIPUTLIST
***检测到glibc***./DvMain:双重自由或损坏(输出):0x0a2149e8***
=========================/lib/libc.so.6[0x934e31]
/lib/libc.so.6[0x937571]
/usr/lib/libstdc++.so.6(运算符delete(void*)+0x22)[0x46465552]
./DvMain(texternalinput::~texternalinput()+0x28)[0x80503a6]
/usr/local/dvstation/lib/libdvlog.so.6(uu gnu cxx::new_分配器::destroy(texternaliputs*)+0x18)[0xb756f192]
/usr/local/dvstation/lib/libdvlog.so.6(标准::_List_base::_M_clear()+0x56)[0xb756d374]
/usr/local/dvstation/lib/libdvlog.so.6(标准::_List_base::~_List_base()+0x1f)[0xb756b595]
/usr/local/dvstation/lib/libdvlog.so.6(std::list::~list()+0x1d)[0xb756abe1]
更新 我也试着找到问题所在。没有欢乐:

vex x86->IR: unhandled instruction bytes: 0xC5 0xF9 0x6E 0x45
==29593== valgrind: Unrecognised instruction at address 0x406e9a8.
==29593==    at 0x406E9A8: std::tr1::__detail::_Prime_rehash_policy::_M_next_bkt(unsigned int) const (hashtable_policy.h:460)
==29593==    by 0x434D522: std::tr1::_Hashtable<DvDbDataBaseObject*, DvDbDataBaseObject*, std::allocator<DvDbDataBaseObject*>, std::_Identity<DvDbDataBaseObject*>, equalp<DvDbDataBase
[...]
==29593== Your program just tried to execute an instruction that Valgrind
==29593== did not recognise.  There are two possible reasons for this.
==29593== 1. Your program has a bug and erroneously jumped to a non-code
==29593==    location.  If you are running Memcheck and you just saw a
==29593==    warning about a bad jump, it's probably your program's fault.
==29593== 2. The instruction is legitimate but Valgrind doesn't handle it,
==29593==    i.e. it's Valgrind's fault.  If you think this is the case or
==29593==    you are not sure, please let us know and we'll try to fix it.
==29593== Either way, Valgrind will now raise a SIGILL signal which will
==29593== probably kill your program.
vex x86->IR:未处理的指令字节:0xC5 0xF9 0x6E 0x45
==29593==valgrind:地址0x406e9a8处的指令无法识别。
==29593==at 0x406E9A8:std::tr1::u详细信息:u Prime\u rehash\u策略::M\u next\u bkt(unsigned int)const(哈希表\u policy.h:460)

==29593==0x434D522:std::tr1::_HashtableIs
TExtInputList
following?
TExtInputList
的定义是什么?我在上面添加了TExtInputList的声明。对于3/5/0规则,“virtual~TSlotData(){}”是否算作“自定义析构函数”?(因此需要实现其他东西?现在这个类和它的基类都没有定义这些东西…我认为空的析构函数不足以调用“规则”。你可以使用这样的工具来帮助你定位可能的指针问题。是的,尝试了valgrind。它会随着“未处理的指令”而消亡。”,这似乎是一个常见的问题。问题中添加了抄本。我将介绍一些内存损坏问题(缓冲区溢出?),这意味着删除虚拟内存只会隐藏另一个问题(导致vtable指针被覆盖)
DvDbPortConfig::deserialize()
DvCfgStream::read SlotDataDvCfgStream SlotData idx: 0 created
DvCfgStream::read created new node for 'SlotData'. pCfg == 0
DvDbPortConfig.cpp noOfExtInput: 1
DvDbPortConfig.cpp Reading external input data
DvCfgStream::read ExternalInputsDvCfgStream ExternalInputs idx: 0 created
DvCfgStream::read created new node for 'ExternalInputs'. pCfg == 0
DvDbPortConfig.cpp stream.readObject found=1
TExternalInputs slot: 1
  - 'ASI'
DvDbPortConfig.cpp pre  mExternalInputs = ExtInputList
DvDbPortConfig.cpp post mExternalInputs = ExtInputList
*** glibc detected *** ./DvMain: double free or corruption (out): 0x0a2149e8 ***
======= Backtrace: =========/lib/libc.so.6[0x934e31]
/lib/libc.so.6[0x937571]
/usr/lib/libstdc++.so.6(operator delete(void*)+0x22)[0x46465552]
./DvMain(TExternalInputs::~TExternalInputs()+0x28)[0x80503a6]
/usr/local/dvstation/lib/libdvlog.so.6(__gnu_cxx::new_allocator<TExternalInputs>::destroy(TExternalInputs*)+0x18)[0xb756f192]
/usr/local/dvstation/lib/libdvlog.so.6(std::_List_base<TExternalInputs, std::allocator<TExternalInputs> >::_M_clear()+0x56)[0xb756d374]
/usr/local/dvstation/lib/libdvlog.so.6(std::_List_base<TExternalInputs, std::allocator<TExternalInputs> >::~_List_base()+0x1f)[0xb756b595]
/usr/local/dvstation/lib/libdvlog.so.6(std::list<TExternalInputs, std::allocator<TExternalInputs> >::~list()+0x1d)[0xb756abe1]
vex x86->IR: unhandled instruction bytes: 0xC5 0xF9 0x6E 0x45
==29593== valgrind: Unrecognised instruction at address 0x406e9a8.
==29593==    at 0x406E9A8: std::tr1::__detail::_Prime_rehash_policy::_M_next_bkt(unsigned int) const (hashtable_policy.h:460)
==29593==    by 0x434D522: std::tr1::_Hashtable<DvDbDataBaseObject*, DvDbDataBaseObject*, std::allocator<DvDbDataBaseObject*>, std::_Identity<DvDbDataBaseObject*>, equalp<DvDbDataBase
[...]
==29593== Your program just tried to execute an instruction that Valgrind
==29593== did not recognise.  There are two possible reasons for this.
==29593== 1. Your program has a bug and erroneously jumped to a non-code
==29593==    location.  If you are running Memcheck and you just saw a
==29593==    warning about a bad jump, it's probably your program's fault.
==29593== 2. The instruction is legitimate but Valgrind doesn't handle it,
==29593==    i.e. it's Valgrind's fault.  If you think this is the case or
==29593==    you are not sure, please let us know and we'll try to fix it.
==29593== Either way, Valgrind will now raise a SIGILL signal which will
==29593== probably kill your program.