Debugging a crash?

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
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Debugging a crash?

Post by 10$man »

Hello everyone, I have been working on a game for a few days and I tried implementing collision detection today. Whenever my player is about to collide with a wall or object, love crashes. There's no error or anything and I am not sure what has gone wrong.
Is there a way I can see some more info as to why the game crashed?
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Debugging a crash?

Post by Roland_Yonaba »

Can't you post a *.love file ?
Or at least, the relevant code.
mathacka
Prole
Posts: 8
Joined: Tue Sep 25, 2012 7:45 pm

Re: Debugging a crash?

Post by mathacka »

Make or go to your config.lua file and add

Code: Select all

t.console = true
then print out what variables you need to see, for instance:

Code: Select all

print("Collision Function: " .. CollisionFunction( x,y,w,h,x2,y2,w2,h2 ) )
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Debugging a crash?

Post by Boolsheet »

When you say LÖVE crashes, you mean it terminates abnormally? You'll have to use the debugging tools of your OS to figure out why that happened. Linux has gdb and Windows has WinDbg (or the built-in one in Visual Studio). On OS X it's LLVD or gdb, I think. However, the Windows build does not have any debugging symbols, so that's not very useful.

The love.physics module has a few issues that could cause such a termination.

If you don't or can't use the debugging tools, you'll have to resort to print debugging. At the start of your code, open a file with the Lua IO and sprinkle your functions with some calls to file:write that write the name of the called function. Always file:flush after writing (or turn the buffering off) because the crash will eat the last few bytes that still are in the memory. When it crashes again, open the file and you'll see roughly where it was last. You can then narrow the search and, when you found the culprit, ask us why that makes it crash. :P
Shallow indentations.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Debugging a crash?

Post by Jasoco »

On OS X I use the Terminal and if a Löve project causes the app itself to outright crash it will print out to the Terminal output. On Windows however the console itself is part of the Löve app and will therefore disappear when it crashes so it's harder to immediately troubleshoot. Follow what Boolsheet says. I don't know where on Windows console crash logs are kept though. Can Löve be run from the DOS Prompt like on OS X and Linux or does it not work that way?

Can you put your project up here for us cross platform people to test and see if it's just Windows?
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: Debugging a crash?

Post by 10$man »

I'm not really interested in posting it, but I guess I will if that's what it takes.
The crash occurs if you walk sidewise into a wall or try to move up or down. You can press w,a,s,d to move.
It's probably a stupid little mistake in the code, which is why I wanted to fix it myself.
Attachments
SotB.zip
(41.37 KiB) Downloaded 127 times
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Debugging a crash?

Post by Boolsheet »

Do not overwrite the global variable print. The default error handler relies on it and explodes if it errors on that.
Shallow indentations.
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: Debugging a crash?

Post by 10$man »

Figures that was the error. Thank you.
brucejs777
Prole
Posts: 6
Joined: Wed Jun 14, 2017 8:06 am

Re: Debugging a crash?

Post by brucejs777 »

mathacka wrote: Fri Jan 04, 2013 9:25 pm Make or go to your config.lua file and add

Code: Select all

t.console = true
Where does that config.lua file go if LOVE is the interpreter ?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Debugging a crash?

Post by zorg »

brucejs777 wrote: Sat Jun 17, 2017 5:04 pm
mathacka wrote: Fri Jan 04, 2013 9:25 pm
>Bumping a thread from 2013
Please quit doing that.

Also, Löve is not an interpreter, it's a framework that uses LuaJIT to compile lua code and run it; your project is run by it finding a main.lua within your project folder (or a zip file with the extension renamed to .love), and you can have many more files next to it, conf.lua being one of them, that is treated a bit specially. See the wiki: Config_Files

Also please don't reply to me in this thread because that would bump it :P
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot], slime and 1 guest