21

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?

1
  • 8
    Sounds like you're most likely corrupting your memory somewhere else and this is just a side-effect. Nov 30, 2009 at 13:59

2 Answers 2

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.

3
  • 1
    Thanks. I will try that. Could have came up with that myself... It's just really slow and since I can't reproduce the error easily it may take a while.
    – hanno
    Nov 30, 2009 at 17:15
  • 1
    how did you solve it ?? Do you have any idea like why did this happen because I am having the same problem ? Jul 27, 2013 at 15:13
  • 2
    @AmitBhaira: I didn't solve it, and I don't think commenting here is going to get hanno's attention. I expect hanno just tried what I suggested, and that Valgrind showed him the problem that was corrupting his list. Have you tried Valgrind? There is not a single, simple solution to this class of problem. Memory corruption problems are notoriously difficult to track down, because they can have so many different causes, and the visible effect of corruption can appear far from the actual cause of the original damage. Jul 27, 2013 at 23:59
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.