Unexplained segfault when resizing the window

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.
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Unexplained segfault when resizing the window

Post by Bigfoot71 »

Hi hi everyone :nyu:

I'm posting because I'm facing a problem that I can't understand or reproduce, I'm working on a fairly big project and I wanted at the last moment to add the possibility of resizing the game window, on this side no problem but very strange thing, if I don't wait about ten seconds before resizing I get a big freeze then a segfault!

So I tried things like with valgrind but having a really slow PC it takes a good ten seconds to start and I can directly resize the window without any error or freeze...

Does anyone have any idea where this could be coming from?

I'm on Löve 11.3 with Linux Mint 20.3 if that helps. (unfortunately I can't share specific code because the project is much too big, I try nevertheless to reproduce, if I succeed I will share).

All I can say is that even removing the `love.resize` function the problem persists.

Edit: Finally it's completely random, I tried twice while waiting a minute in the game menu without doing anything at all, the first time it crashed and the other time it didn't and never when I try with valgrind...
My avatar code for the curious :D V1, V2, V3.
User avatar
GVovkiv
Party member
Posts: 670
Joined: Fri Jan 15, 2021 7:29 am

Re: Unexplained segfault when resizing the window

Post by GVovkiv »

Well, without any code we can't really tell what's wrong. It's may be some library that you use, it's might be somewhere in file main.lua on line 465
If it somewhat random, i might suspect that this might be memory leak, because you create somewhere game objects and forgot to remove them so at some point game crash?
Maybe this is luajit problem. First thing that you might try is jit.off() and if problem gone, then this might be jit and more depth code analyse required

Since you on mint, you could try use love 11.4 appimage instead and see if it makes any difference
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Unexplained segfault when resizing the window

Post by Bigfoot71 »

Thank you for the answer, unfortunately I don't see what I could share relevant for the moment, I mostly posted hoping that a similar behavior has already happened to someone, you never know.

So I can say that the problem does not come from LuaJIT, nor from Löve 11.3 (I tried 11.4), I don't use a C or FFI library (if it could come from that).

It doesn't come from the module I use for the display either (push, scale, pop, etc). I don't see anything in the game menu that could cause a memory leak and still have the same problem removing the "requires" of the other game state files. (freezes and segfault only happen when I resize the window, never at other times)

I'm going to keep looking, if it is, it's very stupid and it's in front of my eyes...
My avatar code for the curious :D V1, V2, V3.
User avatar
GVovkiv
Party member
Posts: 670
Joined: Fri Jan 15, 2021 7:29 am

Re: Unexplained segfault when resizing the window

Post by GVovkiv »

Well, if it happens only at window resize and only then, check everything that depends on love.graphics.height/width(well, window size, yeah)
Maybe something messed up in math related to it?
Also, just to be sure, does it happens only on mint with whatever it uses as window manager?
It could be worth to run game on other window manager and-or DE with different display server (xorg, wayland). Maybe something messed up on this side, who knows
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Unexplained segfault when resizing the window

Post by Bigfoot71 »

Indeed, problem "solved", I just tried several times just now on another PC with Windows and I had no problem. So the problem must indeed come from Mate, Xorg, or whatever else related to my distribution... But why randomly?

I'm also thinking about it, it could possibly come from my NVidia driver, on the PC I'm using I have an old graphics card whose driver is no longer supported by recent kernels, maybe it's due to that.

The strangest thing is when I launch my game with valgrind, the problem no longer occurs except for freezes of a few seconds when resizing, very strange behavior, so I will launch my game from valgrind when I need it on this PC. Sounds stupid but that's all I've found so far, if it ever crashes with valgrind I will share the report.

Otherwise thanks for the advice and if anyone has an idea, I'm all ears! :D
My avatar code for the curious :D V1, V2, V3.
User avatar
GVovkiv
Party member
Posts: 670
Joined: Fri Jan 15, 2021 7:29 am

Re: Unexplained segfault when resizing the window

Post by GVovkiv »

Can this be related to your pc specs?
Maybe you got low ram and vram? What exact gpu? And what specs has windows pc?
I just think, that when you resize window, more content need to be updated and redrawed, but you might be low on memory?
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Unexplained segfault when resizing the window

Post by Bigfoot71 »

GVovkiv wrote: Wed Mar 01, 2023 10:35 am Can this be related to your pc specs?
Maybe you got low ram and vram? What exact gpu? And what specs has windows pc?
I just think, that when you resize window, more content need to be updated and redrawed, but you might be low on memory?
Here is the configuration of the PC on which the problem occurs:

Code: Select all

Memory:
  RAM: total: 3.77 GiB used: 1.68 GiB (44.6%)
CPU:
  Topology: Dual Core model: Intel Core2 Duo P8700 bits: 64 type: MCP 
  L2 cache: 3072 KiB 
  Speed: 925 MHz min/max: 800/2535 MHz Core speeds (MHz): 1: 1596 2: 1596 
Graphics:
  Device-1: NVIDIA G98M [Quadro NVS 160M] driver: nvidia v: 340.108 
  Display: x11 server: X.Org 1.20.13 driver: nvidia 
  unloaded: fbdev,modesetting,nouveau,vesa resolution: 1440x900~60Hz 
  OpenGL: renderer: Quadro NVS 160M/PCIe/SSE2 v: 3.3.0 NVIDIA 340.108 
And here is the config of the Windows PC, it is also an Intel core 2 Duo E8400 with a GTX 1080 and 8gb of ram. (a little overkill, we do what we can ^^)

But actually, I even just saw that a stack overflow could cause a segmentation fault in some cases, here is a case similar to mine in a completely different context: https://stackoverflow.com/questions/422 ... emory-in-c

But I have a slight doubt that it's a stack problem although the problem looks a lot like it, I just tried today with zero programs open and there is no crash when resizing. When I was trying yesterday I had a good dozen Firefox tabs with Gimp open, maybe it's also due to that...

Edit: The problem reappeared when I started watching a Youtube video in PIP.

I have meanwhile, in doubt, increased the size of the stack and the problem is still present even if the freeze is much shorter before the crash.
The ram is not really full when running the game, so I used the command:

Code: Select all

nvidia-smi -l 1
Which gives live vram usage by refreshing every second, consumption goes up from ~120mb/256 during "normal" PC usage (with vscode open in the background) up to 220/256mb when running the game and as soon as I resize the window it drops to ~120mb immediately and then it crashes.
Last edited by Bigfoot71 on Wed Mar 01, 2023 12:33 pm, edited 1 time in total.
My avatar code for the curious :D V1, V2, V3.
User avatar
GVovkiv
Party member
Posts: 670
Joined: Fri Jan 15, 2021 7:29 am

Re: Unexplained segfault when resizing the window

Post by GVovkiv »

Wow, this 4 gb of ram... and nvidia card with 256 gb of ram and from 2008 with really old driver... Yeah, that's sound as possible problem. Try testing with little as possible ram and video usage while running game. When window is resizing, it actually need memory where it will store new surface of window. You can test it by opening any program and run htop or something like that, and start resizing window of said program. You will see, that ram usage will quickly raise, and the bigger window of program, the more ram it wants to store. And faster you resize, more ram will be used until you stop, because, if i understand correctly, ram usage will raise quickier then system will be able to clean in time, so that's might be reason of segfaults

Also
And here is the config of the Windows PC, it is also an Intel core 2 Duo E8400 with a GTX 1080 and 8gb of ram. (a little overkill, we do what we can ^^)
I don't know, sometimes 12 gb of ddr4 and intel i3-10100 with rx570 might be not enough to work in comfortable environment, which includes running several programs, such as browsers, image editors, sounds editor, not only love and some text editor. So i can't really call it "overkill"
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Unexplained segfault when resizing the window

Post by Bigfoot71 »

GVovkiv wrote: Wed Mar 01, 2023 12:17 pm Wow, this 4 gb of ram... and nvidia card with 256 gb of ram and from 2008 with really old driver... Yeah, that's sound as possible problem. Try testing with little as possible ram and video usage while running game. When window is resizing, it actually need memory where it will store new surface of window. You can test it by opening any program and run htop or something like that, and start resizing window of said program. You will see, that ram usage will quickly raise, and the bigger window of program, the more ram it wants to store. And faster you resize, more ram will be used until you stop, because, if i understand correctly, ram usage will raise quickier then system will be able to clean in time, so that's might be reason of segfaults

Also
And here is the config of the Windows PC, it is also an Intel core 2 Duo E8400 with a GTX 1080 and 8gb of ram. (a little overkill, we do what we can ^^)
I don't know, sometimes 12 gb of ddr4 and intel i3-10100 with rx570 might be not enough to work in comfortable environment, which includes running several programs, such as browsers, image editors, sounds editor, not only love and some text editor. So i can't really call it "overkill"
I just edited my last post about using vram.

Otherwise when I said "overkill" it's obviously not the PC itself but the combination of an Intel Core 2 duo with a GTX 1080 that I find a little abused, the GPU can run a lot of games that my CPU struggles to support ^^

Also I know it's a very old machine on which I code but I'm attached to it, I like it my old cuckoo, it doesn't row and holds the road well apart from this problem :ultrahappy:
My avatar code for the curious :D V1, V2, V3.
User avatar
knorke
Party member
Posts: 239
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: Unexplained segfault when resizing the window

Post by knorke »

I also had crashes with löve 11.3 on Linux Mint 20.3
It also seemed memory or graphics related:
https://love2d.org/forums/viewtopic.php ... 75#p250375
It was just drawing a simple tilemap multiple times (splitscreen game) but it would crash if the tilemap array was larger than 100x100 or so. Or when drawing more than certain number of canvases.
After updating to löve 11.4 it did not crash anymore, even with much larger tilemap arrays.
Post Reply

Who is online

Users browsing this forum: No registered users and 64 guests