vector 和 deque 初始化或 push_back 导致 SIGABRT 错误 [英] Vector and deque initialization or push_back causes SIGABRT error
问题描述
我在初始化双端队列或向量时遇到一个奇怪的错误.我正在使用 QtCreator 和 CMake 项目.
I'm getting a weird error, when initializing my deque or vector. I'm using QtCreator and a CMake-Project.
如果我使用双端队列,它会在初始化时中止:
If I use a deque, it aborts on initialization:
std::deque<int> myValues; // <-- abort here
for (int i=0;i<10;++i)
{
myValues.push_back(i);
}
当我使用 deque 时,它在 push_back 时中止:
when I use deque, it aborts on push_back:
std::vector<int> myValues;
for (int i=0;i<10;++i)
{
myValues.push_back(i); // <-- abort here
}
我不知道为什么现在会发生这种情况(一直都是这样).两种中止都发生在 _gnu_cxx::new_allocator<;int >::allocate.
I can't find out why this is happening now (it worked that way all the time). Both aborts happen inside _gnu_cxx::new_allocator< int >::allocate.
有什么提示吗?
提前感谢您的努力!
哈特穆特
推荐答案
这看起来像是程序中其他地方的堆损坏.也就是说,您在某处写入越界或删除无效指针.一旦堆内部结构被破坏,大量的分配可能会使您的程序崩溃.
It looks like a heap corruption in some other place in your program. That is, you write out-of-bounds or delete an invalid pointer somewhere. Once the heap internal structure is corrupted, substantial allocations may crash your program.
这篇关于vector 和 deque 初始化或 push_back 导致 SIGABRT 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!