game crashed while loading saves

This subforum contains all the issues which we already resolved.
Post Reply
kevinma
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

game crashed while loading saves

Post by kevinma » Sat Jan 26, 2019 3:45 am

I'm developing a mod for AI player. Currently finish the IOC container and some simple steering behavior.

How to reproduce:

1. start new game with mod
2. spawn some solders by clicking button 'S'
3. command it to follow by clicking button 'C'
4. save the game
5. quit
5. load the save
6. repeat 2~5 a few times (less than 3) will cause a crash

mod github: https://github.com/kevinmama/PandaAI/tr ... -2019-1-26

crash stack trace:
28.465 Error CrashHandler.cpp:522: Received SIGSEGV
Factorio crashed. Generating symbolized stacktrace, please wait ...
#0 0x0000000100a24342 in Logger::logStacktrace(StackTraceInfo*) (in factorio) (Logger.cpp:521)
#1 0x0000000100a119ed in CrashHandler::writeStackTrace(CrashHandler::CrashReason) (in factorio) (CrashHandler.cpp:173)
#2 0x0000000100a129c4 in CrashHandler::commonSignalHandler(int) (in factorio) (CrashHandler.cpp:524)
#3 0x0000000100a11919 in CrashHandler::SignalHandler(int) (in factorio) (CrashHandler.cpp:537)
#4 0x00007fff628aab3d in 0x00007fff628aab3d
#5 0x000000013d124540 in 0x000000013d124540
#6 0x0000000100cb62e7 in LuaBinder<LuaGuiElement>::callWrapper(lua_State*) (in factorio) (LuaBinder.hpp:326)
#7 0x0000000100d224c8 in luaD_precall(lua_State*, lua_TValue*, int) (in factorio) + 504
#8 0x0000000100d2290b in luaD_call(lua_State*, lua_TValue*, int, int) (in factorio) + 59
#9 0x0000000100d2312d in luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long) (in factorio) + 93
#10 0x0000000100d25253 in GCTM(lua_State*, int) (in factorio) + 243
#11 0x0000000100d2464f in luaC_freeallobjects(lua_State*) (in factorio) + 191
#12 0x0000000100d313b2 in close_state(lua_State*) (in factorio) + 34
#13 0x0000000100942cc5 in LuaGameScript::~LuaGameScript() (in factorio) (LuaState.hpp:20)
#14 0x00000001008a498d in LuaContext::~LuaContext() (in factorio) (LuaContext.cpp:22)
#15 0x00000001008a4bfe in LuaContext::~LuaContext() (in factorio) (LuaContext.cpp:22)
#16 0x0000000100891a6a in Scenario::~Scenario() (in factorio) (Scenario.cpp:747)
#17 0x00000001000514d8 in AppManager::quitGameAndGoToMainMenu(std::__1::function<void ()>) (in factorio) (AppManager.cpp:291)
#18 0x000000010005b20c in InGameMenu::process(AppManager*) (in factorio) (AppManagerStates.cpp:332)
#19 0x000000010004caff in AppManager::process() (in factorio) (vector:633)
#20 0x0000000100763eb5 in MainLoop::prePrepare() (in factorio) (MainLoop.cpp:436)
#21 0x0000000100763aa6 in MainLoop::mainLoopStep(WorkerThread&, MainLoop::HeavyMode) (in factorio) (MainLoop.cpp:523)
#22 0x000000010075e12e in MainLoop::run(Filesystem::Path const&, Filesystem::Path const&, bool, bool, std::__1::function<void ()>, Filesystem::Path const&, MainLoop::HeavyMode) (in factorio) (MainLoop.cpp:338)
#23 0x0000000100751551 in _al_mangled_main (in factorio) (Main.cpp:1130)
#24 0x0000000100e3b097 in +[AllegroAppDelegate app_main:] (in factorio) (osx_app_delegate.m:230)
#25 0x00007fff377da104 in 0x00007fff377da104
#26 0x00007fff628b3305 in 0x00007fff628b3305
#27 0x00007fff628b626f in 0x00007fff628b626f
#28 0x00007fff628b2415 in 0x00007fff628b2415
Stack trace logging done
Attachments
factorio-current.log
crash log
(14.45 KiB) Downloaded 5 times

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

Re: game crashed while loading saves

Post by Rseding91 » Sat Jan 26, 2019 3:56 am

Thanks for the report. Don't use the inspect library. It's known to be buggy and cause crashes.

Aside from that, when I test it in 0.17 it's saying you're giving "nil" in place of direction when calling: entity.walking_state = {walking=boolean, direction=defines.direction} meaning you didn't give any direction when you're meant to.
If you want to get ahold of me I'm almost always on Discord.

kevinma
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

Re: game crashed while loading saves

Post by kevinma » Sat Jan 26, 2019 4:13 am

Rseding91 wrote:
Sat Jan 26, 2019 3:56 am
Thanks for the report. Don't use the inspect library. It's known to be buggy and cause crashes.

Aside from that, when I test it in 0.17 it's saying you're giving "nil" in place of direction when calling: entity.walking_state = {walking=boolean, direction=defines.direction} meaning you didn't give any direction when you're meant to.
thank you, it solved.

Which library should I use in factorio to pretty print tables?

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

Re: game crashed while loading saves

Post by Rseding91 » Sat Jan 26, 2019 4:15 am

serpent. It's included with the game and always loaded.
If you want to get ahold of me I'm almost always on Discord.

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

Re: game crashed while loading saves

Post by Rseding91 » Sat Jan 26, 2019 4:36 am

Additionally it looks like the underlying problem is you're passing an invalid value into set_metatable() for the second parameter during on_load. set_metatable() expects nil (to remove the metatable) or a table (for the new metatable value). You're passing user-data - essentially a function pointer or C object data we've pushed into the Lua state that allows hooking Lua into the C++ game logic.
If you want to get ahold of me I'm almost always on Discord.

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

Re: game crashed while loading saves

Post by Rseding91 » Sat Jan 26, 2019 4:38 am

I also notice you're using __index with your set_metatable() calls (as expected) however if you ever call set_metatable() on one of the LuaObjects gotten back from the Factorio Lua API you'd crash and or corrupt the game state.
If you want to get ahold of me I'm almost always on Discord.

kevinma
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

Re: game crashed while loading saves

Post by kevinma » Sat Jan 26, 2019 7:37 am

In order to reconstruct objects on loading, I need to check if a table is a native object. Can I check with the following code?

Code: Select all

type(object) == 'table' and type(object.__self) == 'userdata'
I change the implement of function is_native_class in kcontainer.lua and fix the issue. It works for LuaPlayer and LuaGUIElement.

the fixed branch https://github.com/kevinmama/PandaAI/tr ... -2019-1-26

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

Re: game crashed while loading saves

Post by Rseding91 » Sat Jan 26, 2019 8:24 am

kevinma wrote:
Sat Jan 26, 2019 7:37 am
In order to reconstruct objects on loading, I need to check if a table is a native object. Can I check with the following code?

Code: Select all

type(object) == 'table' and type(object.__self) == 'userdata'
I change the implement of function is_native_class in kcontainer.lua and fix the issue. It works for LuaPlayer and LuaGUIElement.

the fixed branch https://github.com/kevinmama/PandaAI/tr ... -2019-1-26
Seems strange to me. Shouldn't you know what the data is you have stored based off it's location in the global table?
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”

Who is online

Users browsing this forum: No registered users