device->drop() Throwing Exception

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
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

device->drop() Throwing Exception

Post by kklouzal »

I've been developing an application on my main computer for about a year now and everything is going quite well. Today I decided to test it on my older windows 7 laptop to check the applications performance and it runs great, however, when I exit the application the program crashes. I did some 'print debugging' and found that the crash is happening during a call to 'Device->drop()'

I've tested running the driver on DirectX9.0 and OpenGL mode and it only happens running DirectX. All the drivers and software are up to date on this machine, and in fact this machine has had a fresh copy of windows installed and nothing else has been put on it.
I've also had 5 other people run the application, 1 of which report the crash happens for them as well.

I'm installing visual studio on that machine now so I can run in debug mode to try and get more information here.
Dream Big Or Go Home.
Help Me Help You.
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: device->drop() Throwing Exception

Post by kklouzal »

VS2013 Exception Window:

Code: Select all

Unhandled exception at 0x60D8FC2C (Irrlicht.dll) in Infinity-Engine.exe: 0xC0000005: Access violation reading location 0XFEEFEEF2.
Then the debugger breaks into my code at line:

Code: Select all

m_Device->drop()
Dream Big Or Go Home.
Help Me Help You.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: device->drop() Throwing Exception

Post by mongoose7 »

So m_Device->drop = 0xfeeefeef2? Or haven't you compiled Irrlicht for the debugger? But it is most likely that you are accessing memory that has been freed. (On Linux you could run valgrind.)
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: device->drop() Throwing Exception

Post by kklouzal »

My first conclusion was that I was accessing memory that had been freed, but it working fine on most machines made me think otherwise. Compiling Irrlicht into debug mode and debugging my application still does not allow me to see into Irrlicht.dll to find exactly where the exception occurs. I'm getting

Code: Select all

no symbols loaded for Irrlicht.dll
and when I try to point VS2013 to the Irrlicht.pdb it tells me

Code: Select all

A matching symbol file was not found in this folder.
So I'm sort of at a loss as to what to do now.
Dream Big Or Go Home.
Help Me Help You.
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: device->drop() Throwing Exception

Post by kklouzal »

Aaha! After pulling my hair out and recompiling all sorts of things I was able to get the debugger to break into Irrlicht's source code, here's where the exception is occurring:
IReferenceCounted.h, line 134

So this tells me I'm calling ->drop() on something I shouldn't be? Okay, but why isn't this error consistent across all test machines and why does it only occur when using the DirectX driver?

EDIT: After some digging around in my code I was calling ->drop() on a texture created with driver->getTexture() and that was the issue.
Hopefully someone in the future with a problem like this will find the topic useful!
Dream Big Or Go Home.
Help Me Help You.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: device->drop() Throwing Exception

Post by REDDemon »

That's should be a bug report/feature request, shouldn't Irrlicht warn in some way that?

Assume Irrlicht code is not bugged

Something created with "getSomething" is owned also by Device/Driver. So You know Driver grabbed it once, and therefore should never happen to see refcount <= 0 before dropping it on destruction

if (recount<=0)
log ("User dropped this objects but was not supposed to do so");
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: device->drop() Throwing Exception

Post by kklouzal »

Yes thank you, I agree it should assert/log some message, it took me a few hours digging around to figure out what the root cause was. It was my mistake when I read the function description of "getTexture" I thought it said you should call drop() :P
Dream Big Or Go Home.
Help Me Help You.
Post Reply