I am having problems with a fairly complex code. I wasn't able to produce a short snippet that reproduces the error, so I'll try to explain the problem in words.
我遇到了相当复杂的代码问题。我无法生成一个重现错误的简短片段,因此我将尝试用文字解释问题。
The code crashes randomly with the error
代码随错误而随机崩溃
*** glibc detected *** gravtree: corrupted double-linked list: 0x000000001aa0fc50 ***
Debugging showed that it comes from the line where the codes frees an object. There seems to be nothing wrong with the object. It exists, and I can access it's data at the time the error occurs. The object's destructor is trivial and doesn't do anything.
调试显示它来自代码释放对象的行。对象似乎没有任何问题。它存在,我可以在错误发生时访问它的数据。对象的析构函数是微不足道的,不会做任何事情。
So, I'm kind of stuck. In what kind of circumstances do you expect 'free' to fail?
所以,我有点卡住了。在什么样的情况下,你期望“免费”失败?
2 个解决方案
#1
11
Try running your program under Valgrind. It may point you to an earlier cause, whereas gdb is only breaking in where damage has already occurred.
尝试在Valgrind下运行您的程序。它可能会指向较早的原因,而gdb仅在已经发生损坏的地方突破。
#2
0
As Warren said, Valgrind is usually the best way to find it. The doubly linked list is a base of usually network or binary data handlers, ie in QT QByteArray
or QTcpSocket
. I had the same thing today and it was because I had invalidated an object by deleting it off a map but had previously obtained pointers to data inside of it. It worked sometimes, sometimes not. The higher the load on the system the more likely it would crash.
正如沃伦所说,Valgrind通常是找到它的最好方法。双向链表通常是网络或二进制数据处理程序的基础,即在QT QByteArray或QTcpSocket中。我今天也有同样的事情,那是因为我通过从地图上删除它来使对象无效,但之前已经获得了指向它内部数据的指针。它有时工作,有时不工作。系统负载越高,崩溃的可能性就越大。
#1
11
Try running your program under Valgrind. It may point you to an earlier cause, whereas gdb is only breaking in where damage has already occurred.
尝试在Valgrind下运行您的程序。它可能会指向较早的原因,而gdb仅在已经发生损坏的地方突破。
#2
0
As Warren said, Valgrind is usually the best way to find it. The doubly linked list is a base of usually network or binary data handlers, ie in QT QByteArray
or QTcpSocket
. I had the same thing today and it was because I had invalidated an object by deleting it off a map but had previously obtained pointers to data inside of it. It worked sometimes, sometimes not. The higher the load on the system the more likely it would crash.
正如沃伦所说,Valgrind通常是找到它的最好方法。双向链表通常是网络或二进制数据处理程序的基础,即在QT QByteArray或QTcpSocket中。我今天也有同样的事情,那是因为我通过从地图上删除它来使对象无效,但之前已经获得了指向它内部数据的指针。它有时工作,有时不工作。系统负载越高,崩溃的可能性就越大。