Is this a bug or intended? Memory management issue

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
wqking
Posts: 11
Joined: Wed Nov 14, 2012 9:46 am

Is this a bug or intended? Memory management issue

Post by wqking »

COpenGLFBODepthTexture is inherited from ITexture, which is inherited IReferenceCounted.
And COpenGLFBODepthTexture holds a pointer to IVideoDriver, however, it doesn't grab the Driver.

So if I call driver.addRenderTargetTexture, and store the returned ITexture to somewhere, and I call grap on it.
Assume the object freeing order is not guaranteed, so if I "drop" and free Driver first, and then call ITexture::drop, since COpenGLFBODepthTexture doesn't grab the driver and the driver is already freed, COpenGLFBODepthTexture will try to access a dangling driver pointer in its destructor, which causes crash.

So my question is,
Is it intended that COpenGLFBODepthTexture doesn't grad Driver? To avoid cycling reference? Or it's a bug?
If it's not a bug, does it mean we must enforce the order of freeing object, such as a video driver, or the device, must be free at the last? But that's not quite reasonable, because in a reference count based memory management, we should not assume any object freeing order.

Thanks
http://www.cpgf.org/
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.3 was released. Now supports Irrlicht 3D engine v1.8 in script binding.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Is this a bug or intended? Memory management issue

Post by hybrid »

Yes, sometimes internal usage of such pointers is not properly grab'ed, which is usually a bug. Since these helper textures were not properly integrated into the ressource system, it might have been a problem with the proper release schedule, but I don't remember any such cases here. So I guess it's just missing.
wqking
Posts: 11
Joined: Wed Nov 14, 2012 9:46 am

Re: Is this a bug or intended? Memory management issue

Post by wqking »

Thanks for the clarify.
I changed my code to workaround those kind of bugs.
http://www.cpgf.org/
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.3 was released. Now supports Irrlicht 3D engine v1.8 in script binding.
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: Is this a bug or intended? Memory management issue

Post by chronologicaldot »

Is that going to be changed in the future or would changing that hamper its primary usage?
Post Reply