Physics cause love crash randomly

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Alex22
Prole
Posts: 26
Joined: Wed Jun 02, 2010 5:42 pm

Physics cause love crash randomly

Post by Alex22 »

Hey guys, I have this problem now since quite a long time and I finally chose to hunt this sucker down.

http://dl.dropbox.com/u/1519805/steroid.love
Try the .love out and youll notice that after some shooting around(hold right mouse button) it crashes. I really have no idea how that happens.
The weird thing, it happens without any pattern, sometimes it crashes right on the second or third shot and sometimes it doesn't crash at all(very unlikely).

So I hope this could maybe be a known problem|bug and some wonderboy comes and tells me what im doing wrong :D

Greetings, Alex22.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Physics cause love crash randomly

Post by Taehl »

"for i,v in pairs(shells) do if love.timer.getTime() - v.crttime > v.lifetime then" What are crttime and lifetime, and why aren't they mentioned anywhere else in game.lua?
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
slime
Solid Snayke
Posts: 3159
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Physics cause love crash randomly

Post by slime »

The error that box2d gives when it crashes is

Code: Select all

Assertion failed: (m_pairCount < b2_maxPairs && m_freePair != b2_nullPair), function AddPair, file src/modules/physics/box2d/Source/Collision/b2PairManager.cpp, line 134.
Not sure what that means exactly though.
Alex22
Prole
Posts: 26
Joined: Wed Jun 02, 2010 5:42 pm

Re: Physics cause love crash randomly

Post by Alex22 »

:3 Sorry for my messy code, im working on this for quite a while now and im not the type of person who comments its code properly...

crttime is the time the shell was created and lifetime is the limit in seconds how long it does live until its going to be removed.
The function it is in is doing the mentioned above. (the crttime is set in the Shell:init in classes.lua)
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Physics cause love crash randomly

Post by ivan »

slime wrote:The error that box2d gives when it crashes is

Code: Select all

Assertion failed: (m_pairCount < b2_maxPairs && m_freePair != b2_nullPair), function AddPair, file src/modules/physics/box2d/Source/Collision/b2PairManager.cpp, line 134.
Not sure what that means exactly though.
Box2D has several constants. This script seems to have violated the maximum collisions pair count.
Not 100% sure, but most likely this is caused by trying to create a very large number of shapes.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Physics cause love crash randomly

Post by BlackBulletIV »

slime wrote:The error that box2d gives when it crashes is

Code: Select all

Assertion failed: (m_pairCount < b2_maxPairs && m_freePair != b2_nullPair), function AddPair, file src/modules/physics/box2d/Source/Collision/b2PairManager.cpp, line 134.
Not sure what that means exactly though.
Pretty sure I hit this when creating too many shapes, over 4000 is the mark I think.
Alex22
Prole
Posts: 26
Joined: Wed Jun 02, 2010 5:42 pm

Re: Physics cause love crash randomly

Post by Alex22 »

I'm not sure but I really don't think that the problem is, that too many shapes have been created (does destroying the body, also remove the shapes?)
I placed some variables in my code, which increased everytime a shape was created. The results were, again, completly random and without any pattern.

Btw. @Slime: Where did you get the Error message from? When crashing I only recieve this shitty, unhelpful Windows report thing.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Physics cause love crash randomly

Post by ivan »

Alex22 wrote:I'm not sure but I really don't think that the problem is, that too many shapes have been created
Box2D uses constant-sized arrays so don't be surprised.
After all, Box2D is a C++ library so it's hard to safely export it to Lua without re-writing half the code and making everything 'dynamic'.
Alex22 wrote:(does destroying the body, also remove the shapes?)
Yes.
Alex22 wrote:I placed some variables in my code, which increased everytime a shape was created. The results were, again, completly random and without any pattern.
Because of Lua's garbage collector crashes can often appear random.
Generally, if you are able to produce a C/C++ crash from a Lua script than there's something seriously wrong in your code.
Alex22 wrote:Btw. @Slime: Where did you get the Error message from? When crashing I only recieve this shitty, unhelpful Windows report thing.
He is probably running Love2D in debug mode.
You'll need a C/C++ compiler and all the Love2D source code to do that.
User avatar
slime
Solid Snayke
Posts: 3159
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Physics cause love crash randomly

Post by slime »

Alex22 wrote:Btw. @Slime: Where did you get the Error message from? When crashing I only recieve this shitty, unhelpful Windows report thing.
I ran the game through my console in OS X, and it showed up there.
Alex22
Prole
Posts: 26
Joined: Wed Jun 02, 2010 5:42 pm

Re: Physics cause love crash randomly

Post by Alex22 »

Oh, if anyone cares or has the same problem:

I had a bug in my shape creation code which caused each shape to be created ~5-25 times. Fixing this has stopped the chrasing.
But I find it curious, that box2d already crashes at approximately 1.5k shapes.

Thanks for your help :D
Post Reply

Who is online

Users browsing this forum: slime and 2 guests