Page 1 of 1

Requesting more help - crash this time...

Posted: Mon Apr 20, 2009 12:02 am
by invisisci
Hi all,

I'm getting a crash that I can't diagnose... I found some workarounds but I want to understand what's going on. To reproduce:

* Run attached .love
* You control the big love symbol ("the hero") at the bottom
* There are weird-looking robots zooming past.
* Click the LMB to explode the robots. Note that they spawn "pieces" of themselves when they die. Hero can collect these pieces.
* You don't need to use the mouse any more.
* Instead, use the arrow keys to move the hero. Try to crash into the weird-looking robots.
* If you crash such that the hero collects all the spawned pieces at once, CRASH! I try to have a head on collision to get it reliably.
* It's _very_ easy to get the crash. 5 seconds usually.

The crash symptom is either:

1) Love locks up. Have to terminate process via Task Manager
2) Crash. App window just disappears.

StdError (when I get it) is:

Code: Select all

attempt to call a number value
stack traceback:
	[C]: in function 'update'
	[string "main.lua"]:182: in function <[string "main.lua"]:141>
...which is where I call world:update(dt) inside main:update(dt).

I can reduce and maybe even eliminate the crash by spawning less pieces. In trashbot:collision(a,b,c) I can comment out piece:new() calls one by one, so that a robot spawns only one or two pieces. Then the crash becomes at least very rare. Simply exploding the robots (using LMB) or collecting the pieces with the hero is fine. It's when there's a hero/trashbot collision, and I'm wondering if trying to create/delete something out of order. I can't see it.

So I'm kind of poking at the problem, but I don't actually understand why it's crashing. Can anyone help?

Re: Requesting more help - crash this time...

Posted: Mon Apr 20, 2009 5:30 am
by bartbes
These are the last lines of console output:

Code: Select all

trashbots - main:collision() - collision between "nil" and "table: 0x92f0f80"...
trashbots - piece:collision(%s, %s)
trashbots - piece:destroy() - self destruct activated
	Found myself
	erg...
Segmentation fault
So, this doesn't appear to be the normal crash created by too many objects.. makes me think there's something in piece:destroy(), however I can not read the code right now (busy).

Re: Requesting more help - crash this time...

Posted: Tue Apr 21, 2009 9:11 am
by Gerrit
bartbes wrote:So, this doesn't appear to be the normal crash created by too many objects.. makes me think there's something in piece:destroy(), however I can not read the code right now (busy).
Exactly what I think. You're either trying to move or destroy an object which is already destroyed. And it seems it's the second thing. Just enhance your script to print out the table index of the objects that are created & destroyed to the log and you'll see that before the crash an object (table index 6 in my case) will get destroyed. A couple of lines (in the log) later it'll try to destroy it again and crash.

Nice logging by the way :) I should do that to..but I'm lazy..

Re: Requesting more help - crash this time...

Posted: Tue Apr 21, 2009 3:55 pm
by invisisci
Thanks for the responses, I'm going to investigate piece:destroy() more thoroughly.

The logging is really simple BTW... look at function log(m,s) at the bottom of main. Feel free to use it if you like it!

Re: Requesting more help - crash this time...

Posted: Wed Apr 22, 2009 6:57 am
by invisisci
Fixed now. Deleting the same object twice I think... I fixed it by instead setting a "removeFlag" on the object, and cleaning up at the end of the frame. Much happier now. Thanks for the assistance.