Hi Lövers!
I'm developing a rather large Löve game and am hitting an elusive crash. After playing fine for 30 minutes+, an occasional crash occurs. I can reproduce this in the Visual Studio debugger using the 0.9.1 source code. runtime.cpp :
Object is invalid here, with its _vfptr 0xfeeefeee indicating freed memory, which causes the release() call to fail.
However, this does not give me more info than 'the garbage collector is trying to release an invalid - probably previously released - object'.
Does anyone have any pointers how to debug that? [Efficiently I mean, not 'comment out one system at a time and see if it still happens' - it takes 40+ mins to see if it reproduces (without any guarantees), and the codebase is large]. Or how eg double releases can be detected?
How to debug crashes in the garbage collector
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: How to debug crashes in the garbage collector
Does your lua code use love threads? The reference counting code for LÖVE's objects is unfortunately not thread-safe right now, which I guess might cause an issue like that in some circumstances when threads are used.
Can you figure out what type the object causing the crash is (maybe through the 'flags' field of the Proxy object in w__gc)?
Can you figure out what type the object causing the crash is (maybe through the 'flags' field of the Proxy object in w__gc)?
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: How to debug crashes in the garbage collector
The only times I've had Löve crash because of the garbage collector is when I am doing 3D. (Or if I force stop the collector to debug) And it's because I'm creating a lot of garbage in a short amount of time. Too much for the collector to clean up. Usually tweaking the settings using collectgarbage() will help but when there's a lot of garbage, there'll be a lot of lag while it cleans it up. These days I keep an eye on my garbage amount by printing collectgarbage("count")/1024 somewhere on the screen (Bottom right corner) and can tell when something I've changed is leaking a lot.
Try printing onto the screen while running the game and watch if the number gets really high.
Try printing onto the screen while running the game and watch if the number gets really high.
Last edited by Jasoco on Tue Jan 13, 2015 6:52 pm, edited 1 time in total.
Re: How to debug crashes in the garbage collector
Ah, I didn't know of the use of flags, thanks!
flags 1, 2 and 18 are set - that makes it image data I think.
And yes, we do use threads - for resource loading and AI mostly.
flags 1, 2 and 18 are set - that makes it image data I think.
And yes, we do use threads - for resource loading and AI mostly.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: How to debug crashes in the garbage collector
Are you creating lots of images in rapid succession? Maybe you are running out of memory.
When I write def I mean function.
Re: How to debug crashes in the garbage collector
There are places where we do create lots of images in rapid succession ( before each round ), but that does not seem to be cause of increasing memory. Even if it would, could running out of memory explain a crash like above?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: How to debug crashes in the garbage collector
Could you upload a .love?
Creating lots of images is usually a big no-no.
Creating lots of images is usually a big no-no.
Help us help you: attach a .love.
Re: How to debug crashes in the garbage collector
Are you using meshes? Currently there's a memory leak with mesh management in Löve 0.9.1, see this post:
viewtopic.php?f=4&t=78209#p169886
It made my game to crash too when loading/reloading too many times levels.
viewtopic.php?f=4&t=78209#p169886
It made my game to crash too when loading/reloading too many times levels.
Re: How to debug crashes in the garbage collector
Sorry for asking this on someones elses topic, but this got me curious.Jasoco wrote: These days I keep an eye on my garbage amount by printing collectgarbage("count")/1024 somewhere on the screen (Bottom right corner) and can tell when something I've changed is leaking a lot.
Try printing onto the screen while running the game and watch if the number gets really high.
How much is a lot? I am assuming the value is in megabytes after dividing by 1024, and on my game it keeps hopping between 0.6 and 1.5 which doesnt sound that much. It keeps getting cleaned up on my game maybe roughly every 2 seconds from 1.5 to 0.6.
I tried stacking up one npc with a lot of items, and it uses not so optimized algorithm to count a value for a movement (strategy rpg), and the garbage collector consumption jumped from 1 to 30 during the calculation while the game froze for a second or two.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: How to debug crashes in the garbage collector
kikito wrote:Are you creating lots of images in rapid succession? Maybe you are running out of memory.
The crash report isn't from a memory allocation issue – it's almost definitely a race condition related to LÖVE's reference-counted objects.Fenrir wrote:Are you using meshes? Currently there's a memory leak with mesh management in Löve 0.9.1
I'll see if I can get it fixed for 0.9.x, and if so I'll get you to test an updated build of LÖVE.
EDIT: Here's the latest version of LÖVE 0.9.2 with a fix for you to try: http://love2d.org/builds
Last edited by slime on Thu Jan 15, 2015 5:23 am, edited 1 time in total.
Who is online
Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 3 guests