Page 1 of 1

[1.1.109] Crash on creating Lua context when loading a save

Posted: Thu Aug 08, 2024 7:01 pm
by curiosity
To reproduce:
1. Install my local mod versions, in addition to what you can download from the portal.
2. Try loading the save.

Alas, I didn't think to save the original log, so all you get is a log of me launching Factorio and trying to load the save. FWIW, all three of my autosaves are broken like this, so, whatever it is, it happened more than 10 minutes before this save was made.

Re: [1.1.109] Crash on creating Lua context when loading a save

Posted: Wed Aug 14, 2024 6:49 pm
by curiosity
What I would like to know is what in the mod data is causing the crash, so hopefully I could do something about it. I tried GDB, but it's impenetrable. GDB is not intended to be used without source code. Based on 12 downloads, I assume that someone has looked at this.

Re: [1.1.109] Crash on creating Lua context when loading a save

Posted: Wed Aug 14, 2024 7:17 pm
by DarkShadow44
curiosity wrote:
Wed Aug 14, 2024 6:49 pm
Based on 12 downloads, I assume that someone has looked at this.
Possibly just curious people like me. Anyways, I'm on Arch Linux and confirm the issue. It works if you remove the "factoryplanner-curiosity" mod, and crashes if you have ONLY the "factoryplanner-curiosity" mod.

Figuring out what crashes is easy, you just remove stuff until it works, pinpointing the exactly line it fails at.

Stack trace in lua is
- control.lua:3 - require("__factoryplanner-curiosity__/data/init.lua")
- data/init.lua:6 - Player = require('__factoryplanner-curiosity__/classes/model/Player.lua')
- classes/model/Player.lua:7 - local Library = require('__factoryplanner-curiosity__/classes/model/Library.lua')
- classes/model/Library.lua:6 - local Notifier = require('__factoryplanner-curiosity__/classes/Notifier.lua')
- classes/Notifier.lua:5 - local WeakTable = require('__factoryplanner-curiosity__/classes/WeakTable')
- classes/WeakTable:4 - script.register_metatable('WeakKeyTable', wk_mt)
- Crash in factorio code

I don't know anything about metatables, so I can't help. I don't have source access either, so you probably need a dev to have a look.

Re: [1.1.109] Crash on creating Lua context when loading a save

Posted: Wed Aug 14, 2024 8:05 pm
by boskid
Issue was identified and is fixed for 2.0.

Please do not use weak tables inside of `global` (classes/Notifier.lua, Notifier.subscribe calls WeakTable.with_keys())

Re: [1.1.109] Crash on creating Lua context when loading a save

Posted: Wed Aug 14, 2024 10:01 pm
by curiosity
boskid wrote:
Wed Aug 14, 2024 8:05 pm
Issue was identified and is fixed for 2.0.

Please do not use weak tables inside of `global` (classes/Notifier.lua, Notifier.subscribe calls WeakTable.with_keys())
Thanks for the info. Fixed how? A proper error is displayed or weak tables are supported?

Re: [1.1.109] Crash on creating Lua context when loading a save

Posted: Wed Aug 14, 2024 10:08 pm
by boskid
In 2.0 it will work fine with weak tables. Not using weak tables in 1.1 is just a workaround.

Re: [1.1.109] Crash on creating Lua context when loading a save

Posted: Fri Aug 16, 2024 5:51 pm
by curiosity
Version 1.1.110 wrote:
Fri Aug 16, 2024 5:09 pm
  • Fixed a crash when using weak tables in the lua global table. (114713)
That came quicker than anticipated. Thank you.