Why is it that the same environment, the same test method, when I link my program to libglib-2.0.so.0.7200.2 and libgobject-2.0.so.0.7200.2 there is a memory leak of g_object_unref, while in libglib-2.0.so.0.6800.4 and libgobject-2.0.so.0.6800.4 versions do not have this issue, How do I debug this?
The code does GObjectClass.finalize, but there is a memory release after that, does it have to do with the order of execution, can GObjectClass.finalize only be executed at the end?
And should the multithreaded g_queue_push_head be replaced with g_async_queue_push to be safer?
You’re chaining up to the parent’s implementation of GObjectClass.finalize():
and then you’re accessing the instance data:
This is undefined behaviour: the finalize() implementation inside GObject will call g_type_free_instance() which will free the memory allocated for the instance structure. Any access to that memory is now invalid, and anything can happen.
You need to chain up at the end of the function, or at least after any and all accesses to the instance structure.