love icon indicating copy to clipboard operation
love copied to clipboard

"Failed to initialize filesystem: already initialized" error triggering when a stack overflow occurs

Open FloatingBanana opened this issue 3 years ago • 4 comments
trafficstars

It seems that it only happens under certain conditions because sometimes the stack overflow error is properly displayed, I did some tests but didn't find any clues...

Here's the error message:

Error: [love "boot.lua"]:48: Failed to initialize filesystem: already initialized
stack traceback:
	[C]: in function 'init'
	[love "boot.lua"]:48: in function <[love "boot.lua"]:42>
	[C]: in function 'xpcall'
	[love "boot.lua"]:350: in function <[love "boot.lua"]:348>
	[C]: in function 'xpcall'

I'm on Windows 10

FloatingBanana avatar Jul 26 '22 19:07 FloatingBanana

Are you doing anything funny with the errorhandler? I had a similar sounding issue, and it was to do with my modified errorhandler

pakeke-constructor avatar Jul 28 '22 03:07 pakeke-constructor

No, I did a full search through all files in my project and not even the libraries are touching the errorhandler

FloatingBanana avatar Jul 28 '22 12:07 FloatingBanana

A few people have run into this issue before I think - if anyone has some code that can reproduce it, it'd help a lot with fixing it.

slime73 avatar Jul 31 '22 01:07 slime73

Thanks to @zombrodo I am able to reproduce it about half the time with this code:

function love.load()
    local function x(b)
        if true then
            local a = 2 * b
            x(a)
        end
    end

    x(1)
end

If I turn JIT compilation off by adding jit.off() to the top of the file, it goes away (the normal stack overflow error appears). I suspect it's a combination of this https://github.com/LuaJIT/LuaJIT/issues/618#issuecomment-697004047 as well as the way earlyinit and this loop handles things here (it ends up calling love.boot twice in the situations where the already initialized error happens): https://github.com/love2d/love/blob/main/src/modules/love/boot.lua#L369-L373

I'll have to investigate that earlyinit function a bit to make sure I don't accidentally mess anything up if I change it.

slime73 avatar Jul 31 '22 02:07 slime73

A recent LuaJIT commit appears to fix this for me (probably https://github.com/LuaJIT/LuaJIT/commit/8135de2a0204e6acd92b231131c4a1e0be03ac1c). I'll close this issue once we update megasource's version.

slime73 avatar Feb 25 '23 16:02 slime73

LuaJIT has been updated. love2d/megasource@1025e7b6e08b346823f88f0cad6d68c0804a9975.

MikuAuahDark avatar Apr 18 '23 12:04 MikuAuahDark