Device cleanup crash.

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Device cleanup crash.

Post by disanti »

Hello,

I've been noticing in EVERY project that I've made in Irrlicht, when it gets big enough, it always crashes on device->drop()...

So I'm wondering what could cause this and how to get around it.
NO, it is NOT in a loop. NO, I am NOT dropping it twice. YES, it is global.

Thanks
________
Cancer - breast forums
Last edited by disanti on Sun Feb 27, 2011 11:11 pm, edited 1 time in total.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

i remember that happening when i was dropping something too many times. you could try commenting out all your drops and then put them back in one by one :D
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

Heheheh, great fun! ^_^
This ought to take a while... lets see, 36 source files with about 15,000 lines of code. :P

Question: Is it ok to drop loaded IGUIFonts? I can't think of any other way to destroy them as the IGUIEnvironment doesn't manage them.
________
LOLOL
Last edited by disanti on Sun Feb 27, 2011 11:11 pm, edited 1 time in total.
Guest

Post by Guest »

Taken from IGUIEnvironment.h...

Code: Select all

//! Returns pointer to the font with the specified file name. 
/** Loads the font if it was not loaded before. Returns 0 if the font could not be loaded.
\return
returns a pointer to the font.
This pointer should not be dropped. See IUnknown::drop() for more information. */
virtual IGUIFont* getFont(const c8* filename) = 0;
The IGUIEnvironment doesn't provide an interface for managing the fonts, only getting/loading them. You could always modify the IGUIEnvironment interface to allow removing a font from the cache...

Code: Select all

virtual IGUIFont* findFont(const c8* filename) = 0;
virtual void removeFont(IGUIFont* font) = 0;
and implement those methods in the derived CGUIEnvironment...

Code: Select all

IGUIFont* CGUIEnvironment::findFont(const c8* filename)
{
    if (!filename)
        filename = "";

    f.Filename = filename;
    f.Filename.make_lower();

    s32 index = Fonts.binary_search(f);
    if (index != -1)
        return Fonts[index].Font;

    return 0;
}

void CGUIEnvironment::removeFont(IGUIFont* font)
{
    // could use Fonts.linear_search, but need to define
    // SFont::operator== to compare font pointer and
    // need to fix bug in array linear_search.. it should use op== not op<
    for (irr::u32 i = 0; i < Fonts.size(); ++i)
    {
        if (Fonts[i].Font == font)
        {
            Fonts.erase(i);
            font->drop();
            return;
        }
    }
}
Travis
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

OK, I removed all font->drop()s and it prevented the crash for a whole day! I didn't even touch the code, and it crashes again (this time 12 crash dialogs in a row! XD)

It ALWAYS crashes on device->drop() according to my debugger... Any ideas?
________
New Jersey Medical Marijuana
Last edited by disanti on Sun Feb 27, 2011 11:11 pm, edited 1 time in total.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

OK, after some more debugging, inside of the drop function, I know the following information:

ReferenceCount = -17891602
DebugName = 0xBAADF00D

So I can't even figure out what is crashing it!
:roll:
________
RAMBLER AMERICAN HISTORY
Last edited by disanti on Sun Feb 27, 2011 11:11 pm, edited 1 time in total.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

AND now I seemed to figure it out.. I was being an idiot somewhere in my code by placing an ISceneNode*->drop() instead of ISceneNode*->remove(). WTF was I thinking?! XD
________
HALF-BAKED
Last edited by disanti on Sun Feb 27, 2011 11:11 pm, edited 1 time in total.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

hmm i dont even trust remove(), when you can use smgr->addToDeletionQueue() anywhere without fear of crashes
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply