Strange bug makes me suspicious of video library
Posted: Sat Nov 25, 2017 8:55 am
I'm hoping for some advice on a strange bug caused by a inexplicable interaction between the video library in love2d and my own code. At some point in my program, I play a video. If the video has played and finished playing, a later line of my own code causes a crash. If the video hasn't finished playing (it's still playing), my code doesn't cause the crash.
The line of my code that causes the crash is this:
Normally it crashes with no error (the console also quits) but more rarely I get a proper error report "attempt to call a nil value". The line in question is loading a table into memory by executing as code a string just loaded from file that does nothing but return a table (a way of storing 9 kB of table data outside my main.lua). I can give more details on that if needed. But basically, nothing in that code has anything to do with the video library or my video-related variables.
I have tried removing any code related to the ending of the video (not even testing whether it has ended). The crash still happens (unless the video hasn't finished - then it never crashes).
If I was coding in C then I would suspect some kind of error in my memory handling, but seeing as I basically can't do that in lua then I suspect the video library of some mishandling of something. There is something more that I think probably proves this bug is not of my own making: the exact same code runs fine on someone else's computer (I have Windows 7 and she has Windows 10, we both have the latest Love2d).
I have tried (after the video has played) setting the variable holding the video to nil, and I have tried running garbagecollection(), but this bug still happens. Any advice for how to avoid it gratefully received!
The line of my code that causes the crash is this:
Code: Select all
local slice = loadstring(script)()
I have tried removing any code related to the ending of the video (not even testing whether it has ended). The crash still happens (unless the video hasn't finished - then it never crashes).
If I was coding in C then I would suspect some kind of error in my memory handling, but seeing as I basically can't do that in lua then I suspect the video library of some mishandling of something. There is something more that I think probably proves this bug is not of my own making: the exact same code runs fine on someone else's computer (I have Windows 7 and she has Windows 10, we both have the latest Love2d).
I have tried (after the video has played) setting the variable holding the video to nil, and I have tried running garbagecollection(), but this bug still happens. Any advice for how to avoid it gratefully received!