"glibc free():下一个大小(快速)无效"在vector.push_back上? [英] "glibc free(): invalid next size(fast)" on vector.push_back?

查看:104
本文介绍了"glibc free():下一个大小(快速)无效"在vector.push_back上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行程序时,它有时会崩溃并出现以下错误: " 检测到glibc /pathtoexecutable:free():无效的下一个大小(快速)"

When I run my program it will occasionally crash and give me this error: "glibc detected /pathtoexecutable: free(): invalid next size (fast)"

回溯导致一个成员函数,该成员函数仅调用向量的push_back函数-

The backtrace leads to a member function that just calls a vector's push_back function -

void Path::add(Position p) {path.push_back(p);}

我已经尝试过搜索错误,并且绝大多数问题是人们分配的内存太少.但是,如何在std :: vector<>.push_back上发生这种情况?我可以检查什么?感谢您的帮助.

I have tried googling the error and the very large majority of the problems are people allocating too little memory. But how could that be happening on an std::vector<>.push_back? What can I check for? Any help is appreciated.

推荐答案

您可能在某处进行了无效写入,并浪费了glibc保留的控制信息用于簿记.因此,当它尝试释放东西时,它会检测到异常情况(释放的大小不合理).

You're probably doing an invalid write somewhere and trashing the control information kept by glibc for bookkeeping. Thus, when it tries to free things it detects abnormal conditions (unreasonable sizes to free).

这种事情最糟糕的是,问题并没有在您犯下真正错误的那一刻就显现出来,因此很难发现(经常出现的错误是一个接一个的错误)

What's worst about this kind of thing is that the problem doesn't manifest itself at the point where you made the real mistake so it can be quite hard to catch (it's quite common to be an off-by-one error).

您最好的选择是使用内存调试器. valgrind可能是一个开始(因为您提到了glibc).在glibc消息之前查找大小写无效...".

Your best bet is to use a memory debugger. valgrind could be a start (since you mentioned glibc). Look for "invalid write of size..." before the glibc message.

这篇关于"glibc free():下一个大小(快速)无效"在vector.push_back上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆