LibLoad/LibFree debugging - a test (if you can)

Can anyone confirm that disabling “Use Material Caching” in the bge panel (properties editor -> render tab ->System panel) prevents the crash related to subsequent calls of LibLoad/LibFree?


Yes, I can confirm this.

You should post a example for people to run, so there is no chance of “me” errors.

Thank you very much. I might have found what’s going on. Fishy stuff, of course.
The material cache isn’t cleaned properly when a library is freed. As a matter of fact it isn’t cleaned at all. It grows, and grows and grows. And it also becomes full of freed memory blocks because the pointed data is released anyway.
And all goes well until that same memory block is overwritten - by mere chance. At that point, the poor RAS_BucketManager triggers a SIGSEGV. But the assassin is KX_BlenderSceneConverter and the weapon its poly material/bl material cache maps.
And if that’s true, finding a way to fix it will be fun - and not in the funny way, at least for me.

@blue, I prefer to have existing files tested because I need to know if what I found is the only thing that goes wrong. I have a test but that’s sorted to catch just that particular problem. If disabling material cache still causes a crash, then LibFree/LibLoad has that problem and something more I didn’t find yet.

I have been steering clear of it, due to the aforementioned issues.

@ pgi: It’s nice that you are trying to fix it. Thanks.

Yes! disable material caching makes a script using libFree not crash anymore.
I also use libLoad on another project and I didn’t notice crashes using it.

Actually material caching causes two problems, one memory leak during LibLoad and one crash during LibFree. It’s a double punch, poor bge had no chance :spin:.
I’ll try to see if I can get one or two patches reviewed.
Hopefully that’s the only remaining problem, another one has already been fixed a while ago.