Unusual crashing within the first few seconds of the game with no error message.

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
User avatar
DTmg
Prole
Posts: 6
Joined: Tue Apr 18, 2023 12:47 pm
Contact:

Unusual crashing within the first few seconds of the game with no error message.

Post by DTmg »

I'm making a 2d survival game with randomly generated terrain (I swear I've never played terraria but that is besides the point) and I am running into a rather unusual issue: within the first few seconds of the game launching, more often than not it will freeze for a couple seconds and then close unexpectedly without an error message. Right before it closes it appears to resume again for a few more frames, so I honestly have no idea what is happening. I've looked around the forums already and can't seem to find a solution, the closest I've come is viewtopic.php?p=248403&hilit=freeze+pairs+jit#p248403, but I'm using the latest version of Löve2D (11.5 as of writing) which should include LuaJIT 2.1, and even if it was pairs() acting up I don't believe I'm changing the table while I'm looping through it (any time I spawn a new object I queue it to be added after the frame ends). My code is kind of a mess, so sorry in advance, but I have attached my .love file. If anyone has any idea what is causing this, please let me know, because I am having a hard time debugging this. Thanks in advance!
Attachments
untitled-survival-game.love
(26.47 KiB) Downloaded 31 times

Code: Select all

function explode()
    return explode()
end

explode()
User avatar
slime
Solid Snayke
Posts: 3133
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Unusual crashing within the first few seconds of the game with no error message.

Post by slime »

I haven't looked too thoroughly but I noticed in base.lua and world.lua you're making a bunch of new quads every frame and immediately throwing them away - the garbage collector might not be able to keep up when it's done every frame like that (since Lua's garbage collector doesn't know the full amount of memory used by love objects). I imagine it's impacting performance as well.

Usually you'd just make quads once during loading and reuse those.
User avatar
DTmg
Prole
Posts: 6
Joined: Tue Apr 18, 2023 12:47 pm
Contact:

Re: Unusual crashing within the first few seconds of the game with no error message.

Post by DTmg »

Nice catch, I forgot that newQuad actually creates a new löve object. I've gone ahead and changed that (and it seems to be noticeably performing a bit better overall, so thanks!). However I keep running into the same issue, and I can't seem to pinpoint what might be causing it. It only happens at the very start of the game, I've not had it crash on me in the middle of playing yet. I can't seem to replicate it with the JIT off, and the fact that there is no error message when this happens makes it difficult to debug.

I went ahead and attached the version that doesn't spam quads, thanks for catching that! :)

If anyone else can figure out why it might be crashing seemingly at random, please let me know. It's been causing me quite the headache for the past few days.
Attachments
untitled-survival-game-fixed-quads.love
(26.47 KiB) Downloaded 27 times

Code: Select all

function explode()
    return explode()
end

explode()
User avatar
BrotSagtMist
Party member
Posts: 614
Joined: Fri Aug 06, 2021 10:30 pm

Re: Unusual crashing within the first few seconds of the game with no error message.

Post by BrotSagtMist »

There seems to be no way to reproduce that problem for me.
How often does it actually happen?
obey
User avatar
DTmg
Prole
Posts: 6
Joined: Tue Apr 18, 2023 12:47 pm
Contact:

Re: Unusual crashing within the first few seconds of the game with no error message.

Post by DTmg »

It happens on average maybe 1/5th of the times I open the game, so it's not a one-off. It's been happening for the past few days, so I figured I would ask here since I'm having trouble debugging it.

Code: Select all

function explode()
    return explode()
end

explode()
User avatar
slime
Solid Snayke
Posts: 3133
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Unusual crashing within the first few seconds of the game with no error message.

Post by slime »

Which operating system are you using? If you're on Linux and you've installed love from a package manager instead of the AppImage download on the home page, then love will be using whatever patch version of LuaJIT that the package manager provides instead of a version that's guaranteed to have the pairs fixes.
User avatar
DTmg
Prole
Posts: 6
Joined: Tue Apr 18, 2023 12:47 pm
Contact:

Re: Unusual crashing within the first few seconds of the game with no error message.

Post by DTmg »

I am using windows 10, and I downloaded the 32-bit version of Löve2D 11.5, however I have not been able to reproduce the crash for a good while now on either version (the fixed quads version and the misused quads version). I'm trying to figure out how to consistently reproduce it, but it seems to happen completely at random.

Code: Select all

function explode()
    return explode()
end

explode()
User avatar
Bobble68
Party member
Posts: 160
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: Unusual crashing within the first few seconds of the game with no error message.

Post by Bobble68 »

Sounds kind of similar to an issue I was getting a while back - never found a fix for it, though I know it happened when the game was started from the main menu instead.
Dragon
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 58 guests