[Genhis][2.0.13] Crash inspecting 'character' entities with gvv (ControllerManager::getRealController)

This subforum contains all the issues which we already resolved.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1725
Joined: Sun Oct 14, 2018 8:13 am
Contact:

[Genhis][2.0.13] Crash inspecting 'character' entities with gvv (ControllerManager::getRealController)

Post by Pi-C »

I'm using Lua API global Variable Viewer (gvv) for debugging my mods. That mod can show the environment of registered mods, but it can also be used to inspect Lua objects.

I've got a hard crash (killing Factorio) when I tried to inspect an entity based on the 'character' prototype:

Code: Select all

 703.310 Error CrashHandler.cpp:641: Received SIGSEGV
Factorio crashed. Generating symbolized stacktrace, please wait ...
/tmp/factorio-build-iIfVFv/src/Util/StacktraceToStream.cpp (52): walkStackAndPrintToStream
/tmp/factorio-build-iIfVFv/src/Util/StacktraceToStream.cpp (60): Util::printStacktraceToStream(WriteStream&)
/tmp/factorio-build-iIfVFv/src/Util/Logger.cpp (334): Logger::writeStacktrace(WriteStream*, StackTraceInfo*)
/tmp/factorio-build-iIfVFv/src/Util/Logger.cpp (379): Logger::logStacktrace(StackTraceInfo*)
/tmp/factorio-build-iIfVFv/src/Util/CrashHandler.cpp (183): CrashHandler::writeStackTrace(CrashHandler::CrashReason)
/tmp/factorio-build-iIfVFv/src/Util/CrashHandler.cpp (644): CrashHandler::commonSignalHandler(int)
/tmp/factorio-build-iIfVFv/src/Util/CrashHandler.cpp (652): CrashHandler::SignalHandler(int)
0x7f6b5849ed1f
/tmp/factorio-build-iIfVFv/src/Controller/ControllerManager.cpp (64): ControllerManager::getRealController() const
/tmp/factorio-build-iIfVFv/src/Player.hpp (116): Player::getRealController()
/tmp/factorio-build-iIfVFv/src/GameStateAdapter.cpp (576): GameStateAdapter::getManualRepairer() const
/tmp/factorio-build-iIfVFv/src/Script/LuaControl.cpp (1232): LuaControl::luaReadRepairState(lua_State*)
/tmp/factorio-build-iIfVFv/src/Script/LuaBinder.hpp (156): LuaBinder<LuaEntity>::findAndCallMethod(lua_State*, LuaEntity*, std::basic_string_view<char, std::char_traits<char> >, FlatMap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, LuaBinder<LuaEntity>::FuncWrapper, std::less<void> > const&)
/tmp/factorio-build-iIfVFv/src/Script/LuaBinder.hpp (219): LuaBinder<LuaEntity>::processCommonLuaIndex(lua_State*, LuaEntity*, bool)
/tmp/factorio-build-iIfVFv/src/Script/LuaObjectTemplate.hpp (15): LuaObjectTemplate<LuaEntity, (LuaObjectType)0>::luaIndex(lua_State*)
/tmp/factorio-build-iIfVFv/src/Script/LuaBinder.hpp (281): LuaBinder<LuaEntity>::callWrapperOnObject(lua_State*, LuaEntity*, int)
/tmp/factorio-build-iIfVFv/src/Script/LuaBinder.hpp (339): LuaBinder<LuaEntity>::pushCallWrapperClosureForMetatable(lua_State*, LuaBinder<LuaEntity>::FuncWrapper const*)::{lambda(lua_State*)#1}::operator()(lua_State*) const
/tmp/factorio-build-iIfVFv/src/Script/LuaBinder.hpp (334): LuaBinder<LuaEntity>::pushCallWrapperClosureForMetatable(lua_State*, LuaBinder<LuaEntity>::FuncWrapper const*)::{lambda(lua_State*)#1}::_FUN(lua_State*)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (350): luaD_precall(lua_State*, lua_TValue*, int)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (425): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-iIfVFv/libraries/Lua/lvm.c (103): callTM
/tmp/factorio-build-iIfVFv/libraries/Lua/lvm.c (128): luaV_gettable(lua_State*, lua_TValue const*, lua_TValue*, lua_TValue*)
/tmp/factorio-build-iIfVFv/libraries/Lua/lvm.c (596): luaV_execute(lua_State*)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (426): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (137): luaD_rawrunprotected(lua_State*, void (*)(lua_State*, void*), void*)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (625): luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long)
/tmp/factorio-build-iIfVFv/libraries/Lua/lapi.c (1094): lua_pcallk
/tmp/factorio-build-iIfVFv/libraries/Lua/lbaselib.c (402): luaB_pcall
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (350): luaD_precall(lua_State*, lua_TValue*, int)
/tmp/factorio-build-iIfVFv/libraries/Lua/lvm.c (717): luaV_execute(lua_State*)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (426): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (137): luaD_rawrunprotected(lua_State*, void (*)(lua_State*, void*), void*)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (625): luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long)
/tmp/factorio-build-iIfVFv/libraries/Lua/lapi.c (1094): lua_pcallk
/tmp/factorio-build-iIfVFv/libraries/Lua/lbaselib.c (402): luaB_pcall
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (350): luaD_precall(lua_State*, lua_TValue*, int)
/tmp/factorio-build-iIfVFv/libraries/Lua/lvm.c (717): luaV_execute(lua_State*)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (426): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (137): luaD_rawrunprotected(lua_State*, void (*)(lua_State*, void*), void*)
/tmp/factorio-build-iIfVFv/libraries/Lua/ldo.c (625): luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long)
/tmp/factorio-build-iIfVFv/libraries/Lua/lapi.c (1094): lua_pcallk
/tmp/factorio-build-iIfVFv/src/Util/LuaHelper.cpp (5027): LuaHelper::pCallWithStackTrace(lua_State*, int, int)
/tmp/factorio-build-iIfVFv/src/Script/LuaGameScript.cpp (7111): LuaGameScript::signallingPCall(lua_State*, int, int)
/tmp/factorio-build-iIfVFv/src/Script/LuaGameScript.cpp (689): LuaGameScript::runEventHandler(LuaEventType, int)
/tmp/factorio-build-iIfVFv/src/Script/LuaEventDispatcher.cpp (765): LuaEventDispatcher::run(LuaEventType, MapTick, bool (LuaGameScript::*)(GameAction const&), GameAction const&)
/tmp/factorio-build-iIfVFv/src/Script/LuaEventDispatcher.cpp (441): LuaEventDispatcher::dispatch(GameAction const&, MapTick)
/tmp/factorio-build-iIfVFv/src/GameActionDispatcher.cpp (15): GameActionDispatcher::send(GameAction const&)
/tmp/factorio-build-iIfVFv/src/GameActionHandler.cpp (2722): GameActionHandler::guiClick(InputAction const&, Player*)
/tmp/factorio-build-iIfVFv/src/GameActionHandler.cpp (353): GameActionHandler::actionPerformed(InputAction const&)
/tmp/factorio-build-iIfVFv/src/Input/InputSource.cpp (75): InputSource::flushToListeners(InputAction const&, bool)
/tmp/factorio-build-iIfVFv/src/Input/InputSource.cpp (67): InputSource::flushActions(bool, MapTick)
/tmp/factorio-build-iIfVFv/src/Input/PlayerInputSource.cpp (517): PlayerInputSource::flushActions(bool, MapTick)
/tmp/factorio-build-iIfVFv/src/GameActionHandler.cpp (388): GameActionHandler::update(std::function<void ()>)
/tmp/factorio-build-iIfVFv/src/GameActionHandler.cpp (362): GameActionHandler::update(std::function<void ()>)
/tmp/factorio-build-iIfVFv/src/MainLoop.cpp (1340): MainLoop::gameUpdateStep(MultiplayerManagerBase*, Scenario*, AppManager*, MainLoop::HeavyMode)
/tmp/factorio-build-iIfVFv/src/MainLoop.cpp (1205): MainLoop::gameUpdateLoop(MainLoop::HeavyMode)
/opt/gcc-13.2.0/include/c++/13.2.0/bits/std_function.h (591): std::function<void ()>::operator()() const
/tmp/factorio-build-iIfVFv/src/Util/WorkerThread.cpp (69): WorkerThread::loop()
/tmp/tmp.dlP10F34z6/objdir/../gcc-13.2.0/libstdc++-v3/src/c++11/thread.cc (104): execute_native_thread_routine
0x7f6b584f1111
0x7f6b5856f8f7
0xffffffffffffffff
Stack trace logging done
 705.854 Error CrashHandler.cpp:190: Map tick at moment of crash: 867
 705.854 Error Util.cpp:95: Unexpected error occurred. If you're running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio forums.
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.
 715.577 Uploading log file
 715.688 Info SystemUtil.cpp:871: Started /home/pc/Games/Factorio/factorio_2.0/bin/x64/factorio; trampoline PID: 250098
How to reproduce:
  • Start a new freeplay game with just the mods 'crashtest' (attached) and 'gvv'. In on_init, 'crashtest' will place a car and a character entity next to the remnants of the space-ship, and store them in 'storage.entities'.
  • Enter '/gvv' on the chat console to open the GUI of 'gvv'.
  • Switch to tab 'storage'.
  • In the left column, click the button 'crashtest'.
  • In the panel on the right, open tab 'remote.call("__crashtest__gvv", "storage")'.
  • Open tab 'entities' below it.
  • The table has the elements 'car' and 'character'.
  • Right-click the value of 'car' (the blue text 'LuaEntity'). The view will switch to tab 'property' where you can see the current properties of the car.
  • Switch back to tab 'storage' and right-click the value of 'character'.
  • Enjoy the crash! :-)
Additional information
So far, I've only got the crash when I was trying to inspect a LuaEntity of type 'character'. Everything works as expected for other entities (e.g. of type 'car') and other LuaObjects (e.g. LuaSurface).

Apparently, the crash happens iff the inspected LuaEntity ('character') is not connected to a player:
  • Select the character to the right of the car and use the command

    Code: Select all

    /c game.player.selected.associated_player = game.player
    Inspecting the character will crash the game.
  • Select the character to the right of the car and use the command

    Code: Select all

    /c game.player.character = game.player.selected
    Inspecting the character will succeed.
Attachments
crashtest_0.0.1.zip
(819 Bytes) Downloaded 11 times
crash.log
(17.67 KiB) Downloaded 9 times
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Genhis
Factorio Staff
Factorio Staff
Posts: 591
Joined: Wed Dec 24, 2014 8:19 am
Contact:

Re: [Genhis][2.0.13] Hard crash when inspecting 'character' entities with gvv

Post by Genhis »

Thanks for the report. Last time I apparently didn't catch all issues, so hopefully this is the last one of its kind. :D Fixed for the next release.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1725
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: [Genhis][2.0.13] Hard crash when inspecting 'character' entities with gvv

Post by Pi-C »

That was quick – thank you for the fix!
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Resolved Problems and Bugs”