[0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

This subforum contains all the issues which we already resolved.
Post Reply
project6
Inserter
Inserter
Posts: 22
Joined: Sat Aug 15, 2015 10:31 pm
Contact:

[0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

Post by project6 »

The following code block in control.lua will run happily. However it will leave Factorio in a state where if you process the wrong bit of data, if you try to restart, or if you just try to quit to the main menu the game will crash to desktop (usually without a log):

Code: Select all

local inspect = require 'inspect'

local filter = function(item)
    return item
end

local function player_joined()
    global.make_inspect_crash_factorio = game.players[1]
    local dump_string = inspect(global, {process = filter})
    if dump_string then
        game.write_file('dump.lua', dump_string)
        game.print('dumped')
    end
end

script.on_event(defines.events.on_player_joined_game, player_joined)
Since inspect is bundled with Factorio I (incorrectly) assumed it wasn't going to be an issue to use it and all the options therein. In hindsight it makes total sense that you can't run a metatable or metatable elements or whatever through a function the way I did. Getting to that conclusion cost me about 6 hours time though because I wasn't sure where the issue was coming from.

It would be greatly appreciated if this restriction were documented in some way, even if it's just a 1-line throwaway comment at the top of inspect.lua itself.

Thanks.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

Post by Rseding91 »

Thanks for the report. I don't know why we shipped the "inspect" library with Factorio. It shouldn't have been - I'm going to remove it for 0.17.

As for why it crashes I have no idea. The only reason it would crash is if the inspect library is doing something it shouldn't be - which seems likely. You can just use serpent.block() with pretty format options if you want to dump a table in human readable format.
If you want to get ahold of me I'm almost always on Discord.

project6
Inserter
Inserter
Posts: 22
Joined: Sat Aug 15, 2015 10:31 pm
Contact:

Re: [0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

Post by project6 »

You can just use serpent.block
The reason I use inspect for debugging now is serpent.block's previous failure. :(

Image

Thanks for addressing the bug I reported though. :)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

Post by Rseding91 »

Not sure what you're doing but it works perfectly fine for me: https://i.imgur.com/nxBNPjl.png
If you want to get ahold of me I'm almost always on Discord.

project6
Inserter
Inserter
Posts: 22
Joined: Sat Aug 15, 2015 10:31 pm
Contact:

Re: [0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

Post by project6 »

We ended up finding out what the issue with serpent is: block() chokes on large numerical table keys
Is fine.
/c game.print(serpent.block({[2147483646] = true, [2147483647] = true}))

Is not fine.
/c game.print(serpent.block({[2147483647] = true, [2147483648] = true}))

2147483647 being int32.maxValue
Related: https://github.com/pkulchenko/serpent/issues/34

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

Post by Rseding91 »

You don't want serpent.block since it's going to show you the data in a format that actually isn't in your table (sorting). You want serpent.dump which will give you what you actually have in the table in string form.

Regarding the sorting issue: I can probably just change the logic in the version of Lua we use to use 64 bit integers (since it's actually using them internally - just not in the code which formats numbers when using %d or %i).
If you want to get ahold of me I'm almost always on Discord.

project6
Inserter
Inserter
Posts: 22
Joined: Sat Aug 15, 2015 10:31 pm
Contact:

Re: [0.16.51] Running LuaObjects through inspect's "process" will crash factorio to desktop

Post by project6 »

Found out today that you did indeed change the logic of the lua version and wanted to give my thanks. :)
(Was hard to be sure since this issue could have been marked resolved when `inspect` was removed)

Post Reply

Return to “Resolved Problems and Bugs”