Crash when debugging in VS.NET

Started by lemmy101, Tue 11/03/2008 16:46:20

Previous topic - Next topic

lemmy101

Hi CJ, I've got a strange crash that's happening with the lastest beta of AGS that only occurs when I'm debugging, which is making it impossible to debug the game.

Testing out the amazing new noexceptionhandling thing (woot) it appears its crashing inside AGS not the plug-in but since it's happening between two AGX update calls I'm not certain what is causing it.

---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x0046A514 ; program pointer is +5, ACI version 3.01.1012, gtags (17,64)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.

Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK   
---------------------------

CrashDump: http://www.lemmyandbinky.com/CrashInfo.3.01.1012.dmp

If you could give me some idea of where to look that would be much appreciated. :)

Thanks,

lemmy

Pumaman

That's a crash attempting to render one of the sprites to the screen. What sort of thing are you doing in your plugin? Could you have potentially freed a sprite that was still in use, or something like that?

lemmy101

Does this include character sprites at all? All we've got there is vanilla AGS gui, background, characters and text so I'm not freeing anything at all as far as I can tell. :-\

Basically all I'm doing in cases when it crashes is making calls to SayBackground, and setting views/frames of characters. :S

Will look into it more and see if I can provide you with any extra info. I guess unless I'm fast that'll probably be after the maintainence! :)

Thanks again CJ!

lemmy101

#3
Hi CJ. It seems to be directly related to me calling SayBackground, which is strange if the crash happened in drawing a sprite :( :

//-----

const char* szToPass = GetAGS()->CreateScriptString(GetStringStore()->GetString(nSpeech));
SayBackground = (void (*) (AGSCharacter*, const char*))GetAGS()->GetScriptFunctionAddress("Character::SayBackground^1");
SayBackground(GetAGS()->GetCharacter(m_nID), szToPass);

//-----

If I comment these lines out then it works perfectly (but I get no text appearing, obviously. :)

As I said, this only crashes when running through the debugger. It's completely fine otherwise.

What is the lifetime of strings created using CreateScriptString? Perhaps these are getting deleted and causing me to trash sprite memory only when debugger is running, or something weird?

Thanks,

lemmy

Pumaman

Any managed script objects that you create (including Strings) can be deleted when their reference count reaches 0. In your case, since the reference count is never incremented from 0, it could get destroyed at any time.

You can try using IncrementManagedObjectRefCount and DecrementManagedObjectRefCount to manage the life of the string -- but in this case here you don't really need a managed string at all -- you could just pass a standard const char* into SayBackground.

The other question is, at what point are you running that code? Is it in response to a script command, or is it running within an AGSE_* event? The latter could be dangerous to do.

lemmy101

#5
Ooooh, an AGSE_ event is where ALL my stuff is updated.

It was just a nice way of lowering the amount of set up to implement our plugin. Seemed to work fine in 2.72 so I saw no problem... but if that could be causing problems then...

Wow, I'll try changing this. Thanks CJ! :)

I can use a raw char * in an AGS call? Didn't realise that. So what IS the correct use of CreateScriptString?

Thanks muchly!

lemmy

lemmy101

That works a treat! Both the crash and the weird text problem!

Thanks CJ! :)

Pumaman

Glad it's sorted!

QuoteSo what IS the correct use of CreateScriptString?

It's for when you want to provide a script function in your plugin that returns a String to the script.

SMF spam blocked by CleanTalk