Intentionally causing crashes...

Started by Technocrat, Thu 26/11/2009 21:21:49

Previous topic - Next topic

Technocrat

Bit of an odd question perhaps, but for the purpose of a game, I'm looking to cause the game to crash when then user does something. Not just "close down and pretend it's a crash", but a proper, error-message creating crash, for authenticity's sake.

A lot of the time when I'm making something in the script that'll lead to a mistake, the game refuses to compile. I've managed to cause stack overflow errors, but what other kinds of interesting problems can I deliberately cause and how, for variety's sake?

Calin Leafshade

A missing event handler will compile but error.


suicidal pencil


Ryan Timothy B

I'm not sure why you'd want to intentionally crash AGS.  If it's for a game, I would find it quite annoying and/or unprofessional.  But I imagine you have your reasons...

Gilbert

Well, it's been done in games already. As far as I remember, at least one AGS game (I forget which) did this as a joke when you beat the game. There may be more.

But since those games were made with earlier versions of AGS the same method may not be applicable now (due to scripting system changes and improved error handling and such).

One particular trick you can use is to try to do illegal stuff such that the editor isn't smart enough to spot at compile time. A very simple way is to access an array with an out-of-bound index. Since if you put the index directly into the script the game may not compile (I'm not sure about this) you may indirectly use a variable as the index instead.

Something like:
Code: ags

int blah[2];
int bigindex=10;
blah[bigindex]=4;

This should crash the game, as since V2.7 array bound checks are implemented (before V2.7 the engine will just go on, corrupting memory and would possibly cause undesired fatal effects).

Wonkyth

I assume that the AbortGame() method is out of the question?
"But with a ninja on your face, you live longer!"

Technocrat

Of course, a game crashing when you don't expect it to is annoying, but in this case there's a good reason for it (I promise!)

Some interesting ideas, merci beaucoup! Looks like I've got some crashes to engneer...

Charity

You could do an infinite while loop, though it'll lock up before crashing, which might be annoying.  Or is that the same as a stack overflow?

suicidal pencil

#8
Quote from: Lyaer on Sat 28/11/2009 08:30:40
You could do an infinite while loop, though it'll lock up before crashing, which might be annoying.  Or is that the same as a stack overflow?

No. A stack overflow is when too much memory is used in the call stack.

Like so:
Code: ags

function sub1()
{
  sub1();
}


Calling that function will result in an infinite recursion loop, and a Stack Overflow.

SMF spam blocked by CleanTalk