Page 1 of 1

[0.18.32] Crash to desktop when resuming autosave under debugger.

Posted: Wed Jun 24, 2020 11:36 am
by mrudat
What did you do?
Started Factorio under the debugger to check to see if the mod I'm updating works as designed.

Tried to resume the latest autosave.
What happened?
Factorio crashed to desktop.
What did you expect to happen instead?
Perhaps an error message of some sort saying that this chunk of Lua did something silly?

Re: [0.18.32] Crash to desktop when resuming autosave under debugger.

Posted: Wed Jun 24, 2020 6:07 pm
by boskid
I can easily reproduce this issue by having a save file that has control.lua:

Code: Select all

setmetatable(_G, {__index=function()assert(false)end})
log=nil
However i am not considering this to be worth fixing. Overwriting log function is not allowed and will throw "Detected modification of the global 'log' function.". Overwriting log function and then setting metatable over _G (or _ENV as jarg would said) and throwing when trying to access log results in such crash.

Re: [0.18.32] Crash to desktop when resuming autosave under debugger.

Posted: Wed Jun 24, 2020 6:18 pm
by justarandomgeek
I'll dig into this more shortly, but yes, it is almost certainly caused by the debugger doing a little bit of evil to convert log() calls to debug console events with clickable links to source. You can disable this functionality for now by setting

Code: Select all

"hookLog": false
in your launch.json, which should allow it to work as-is. I suspect when i get to looking it will turn out that one or more of these mods is setting a metatable on _ENV/_G without checking if there's already one, and possibly even directly overwriting the parts of it that the debugger uses for various functionality (such as sorting all the builtin globals out of sight when you don't want them cluttering up Variables view).

Re: [0.18.32] Crash to desktop when resuming autosave under debugger.

Posted: Thu Jun 25, 2020 11:06 am
by mrudat
Good enough for me.

Thanks for looking into it. =)

Re: [0.18.32] Crash to desktop when resuming autosave under debugger.

Posted: Sat Jun 27, 2020 2:09 pm
by justarandomgeek
Minor follow up now that this is in resolved: We've changed the way the debugger `log()` hook works to no longer allow constructing this crash with the latest factorio(0.18.34) and debugger(0.18.25) when both are updated (if either is old it'll still use the old way).