Help on a tenacious bug

Good day gentlemen !

Since yesterday, I’ve been fixing all the memory issues in my application. Turns out now that it’s clean (only a few uninitialized jumps from Rocket), everything has gone to shit :frowning: !
And I’m fixing it one by one.

Usually I at least have proper errors and control over which code exactly crashed, but right now I have something happening in Panda3D while reacting to a Rocket event.

What’s happening ?
On the Rocket side, I have a listener on a click event, and when that click event is triggered, here is what happen:

game: built/include/mutexPosixImpl.I:129: void ReMutexPosixImpl::acquire(): Assertion `result == 0' failed.

It happens before my RocketEventListener is executed.

So it’s pretty hard to understand where it came from.
Can I have some clues about what may have caused something like that to happen ? If I knew what causes this, maybe I could pin the bug.

Thanks !

This usually means you have some code that’s operating on a destructed mutex object, which in turn implies that you’ve got a destructed object of some other kind still in play.

That is, something got explicitly deleted while it’s still being used.

David

Well then that’s quite curious. I have no idea why this happened, but it turned out the issue disappeared without a single change in the code (I had not only to clean all the compilation files, I also had to remove every CMake temporary crap).

On a related subject, it’s becoming very disabling the way I can’t check anything about memory.
I have tremendous leaks, but I am completely unable to pin them down. I use valgrind to track the leaks usually, but since none of the memory management is done directly from my code, valgrind can’t show me where do I wrote code the leaked.

I surrendered and checked myself if I removed all the nodes that I created, and as far as I know I am. But this can’t be true of course. Not with tens of megabytes leaking each time I load a menu or a level.

Is there a good and easy way to search for leaks in a Panda3D C++ application ?

I have tremendous leaks, but I am completely unable to pin them down. I use valgrind to track the leaks usually, but since none of the memory management is done directly from my code, valgrind can’t show me where do I wrote code the leaked.

This is a difficult problem in general. It is made even more difficult by the fact that many things which appear to be leaks (because you can see memory usage growing) are in fact not leaks at all–Panda maintains a number of caches internally to improve performance, and it is normal for memory usage to grow as these caches fill up. However, eventually the caches will reach their limit or be emptied, and memory usage will stop growing.

Many people ask about similar questions from time to time. See, for example, this thread.

David

Oh my ! Indeed, if I use the garbage collector on textures whenever I go back to the main menu, the leak goes from nearly 10MB to just 1MB (and this MB might come from the other caches).

I didn’t know pstat could be used to check so much things. Looks like I actually have no leaks at all, just a lot of unused geom cache.

Thank you for the tip !

For the record, the mutex error is a known bug in Panda. I have not been able to track it down due to my inexperience with threading.