Lua API global Variable Viewer (gvv)

by Ritn

This is a debugging tool. This mod adds commands /gvv and others and a hotkey(Ctrl+Shift+V) to allow you to check _G and global table of map or each mods. Only admins can use command if it is multiplay game. You have to input some code for temporary accessibility or have to edit "control.lua" of other mod or map to access global table of the mod or map. See "Helper" tab for instructions.

Utilities
8 days ago
1.0 - 2.0
3.14K

b Hard crash on trying to inspect LuaEntity

5 days ago
(updated 5 days ago)

Hi! I've just got a hard crash (meaning that it killed Factorio) using gvv. I am not sure whether this is a bug in the mod or in Factorio. Here is the log:

 267.869 Player 0 ran command: chars = game.surfaces.minime_character_previews_character.find_entities()
 271.173 Player 0 ran command: for k, v in pairs(chars) do game.print(serpent.line(v)) end
 292.138 Error CrashHandler.cpp:641: Received SIGSEGV
Factorio crashed. Generating symbolized stacktrace, please wait ...
/tmp/factorio-build-fEKnzZ/src/Util/StacktraceToStream.cpp (52): walkStackAndPrintToStream
/tmp/factorio-build-fEKnzZ/src/Util/StacktraceToStream.cpp (60): Util::printStacktraceToStream(WriteStream&)
/tmp/factorio-build-fEKnzZ/src/Util/Logger.cpp (334): Logger::writeStacktrace(WriteStream*, StackTraceInfo*)
/tmp/factorio-build-fEKnzZ/src/Util/Logger.cpp (379): Logger::logStacktrace(StackTraceInfo*)
/tmp/factorio-build-fEKnzZ/src/Util/CrashHandler.cpp (183): CrashHandler::writeStackTrace(CrashHandler::CrashReason)
/tmp/factorio-build-fEKnzZ/src/Util/CrashHandler.cpp (644): CrashHandler::commonSignalHandler(int)
/tmp/factorio-build-fEKnzZ/src/Util/CrashHandler.cpp (652): CrashHandler::SignalHandler(int)
0x7fcce3525d1f
/tmp/factorio-build-fEKnzZ/src/Controller/ControllerManager.cpp (64): ControllerManager::getRealController() const
/tmp/factorio-build-fEKnzZ/src/Player.hpp (116): Player::getRealController()
/tmp/factorio-build-fEKnzZ/src/GameStateAdapter.cpp (576): GameStateAdapter::getManualRepairer() const
/tmp/factorio-build-fEKnzZ/src/Script/LuaControl.cpp (1232): LuaControl::luaReadRepairState(lua_State*)
/tmp/factorio-build-fEKnzZ/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-fEKnzZ/src/Script/LuaBinder.hpp (219): LuaBinder<LuaEntity>::processCommonLuaIndex(lua_State*, LuaEntity*, bool)
/tmp/factorio-build-fEKnzZ/src/Script/LuaObjectTemplate.hpp (15): LuaObjectTemplate<LuaEntity, (LuaObjectType)0>::luaIndex(lua_State*)
/tmp/factorio-build-fEKnzZ/src/Script/LuaBinder.hpp (281): LuaBinder<LuaEntity>::callWrapperOnObject(lua_State*, LuaEntity*, int)
/tmp/factorio-build-fEKnzZ/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-fEKnzZ/src/Script/LuaBinder.hpp (334): LuaBinder<LuaEntity>::pushCallWrapperClosureForMetatable(lua_State*, LuaBinder<LuaEntity>::FuncWrapper const*)::{lambda(lua_State*)#1}::_FUN(lua_State*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (350): luaD_precall(lua_State*, lua_TValue*, int)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (425): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-fEKnzZ/libraries/Lua/lvm.c (103): callTM
/tmp/factorio-build-fEKnzZ/libraries/Lua/lvm.c (128): luaV_gettable(lua_State*, lua_TValue const*, lua_TValue*, lua_TValue*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/lvm.c (596): luaV_execute(lua_State*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (426): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (137): luaD_rawrunprotected(lua_State*, void (*)(lua_State*, void*), void*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (625): luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long)
/tmp/factorio-build-fEKnzZ/libraries/Lua/lapi.c (1094): lua_pcallk
/tmp/factorio-build-fEKnzZ/libraries/Lua/lbaselib.c (402): luaB_pcall
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (350): luaD_precall(lua_State*, lua_TValue*, int)
/tmp/factorio-build-fEKnzZ/libraries/Lua/lvm.c (717): luaV_execute(lua_State*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (426): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (137): luaD_rawrunprotected(lua_State*, void (*)(lua_State*, void*), void*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (625): luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long)
/tmp/factorio-build-fEKnzZ/libraries/Lua/lapi.c (1094): lua_pcallk
/tmp/factorio-build-fEKnzZ/libraries/Lua/lbaselib.c (402): luaB_pcall
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (350): luaD_precall(lua_State*, lua_TValue*, int)
/tmp/factorio-build-fEKnzZ/libraries/Lua/lvm.c (717): luaV_execute(lua_State*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (426): luaD_call(lua_State*, lua_TValue*, int, int)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (137): luaD_rawrunprotected(lua_State*, void (*)(lua_State*, void*), void*)
/tmp/factorio-build-fEKnzZ/libraries/Lua/ldo.c (625): luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long)
/tmp/factorio-build-fEKnzZ/libraries/Lua/lapi.c (1094): lua_pcallk
/tmp/factorio-build-fEKnzZ/src/Util/LuaHelper.cpp (5025): LuaHelper::pCallWithStackTrace(lua_State*, int, int)
/tmp/factorio-build-fEKnzZ/src/Script/LuaGameScript.cpp (7108): LuaGameScript::signallingPCall(lua_State*, int, int)
/tmp/factorio-build-fEKnzZ/src/Script/LuaGameScript.cpp (689): LuaGameScript::runEventHandler(LuaEventType, int)
/tmp/factorio-build-fEKnzZ/src/Script/LuaEventDispatcher.cpp (765): LuaEventDispatcher::run(LuaEventType, MapTick, bool (LuaGameScript::*)(GameAction const&), GameAction const&)
/tmp/factorio-build-fEKnzZ/src/Script/LuaEventDispatcher.cpp (441): LuaEventDispatcher::dispatch(GameAction const&, MapTick)
/tmp/factorio-build-fEKnzZ/src/GameActionDispatcher.cpp (15): GameActionDispatcher::send(GameAction const&)
/tmp/factorio-build-fEKnzZ/src/GameActionHandler.cpp (2722): GameActionHandler::guiClick(InputAction const&, Player*)
/tmp/factorio-build-fEKnzZ/src/GameActionHandler.cpp (353): GameActionHandler::actionPerformed(InputAction const&)
/tmp/factorio-build-fEKnzZ/src/Input/InputSource.cpp (75): InputSource::flushToListeners(InputAction const&, bool)
/tmp/factorio-build-fEKnzZ/src/Input/InputSource.cpp (67): InputSource::flushActions(bool, MapTick)
/tmp/factorio-build-fEKnzZ/src/Input/PlayerInputSource.cpp (517): PlayerInputSource::flushActions(bool, MapTick)
/tmp/factorio-build-fEKnzZ/src/GameActionHandler.cpp (388): GameActionHandler::update(std::function<void ()>)
/tmp/factorio-build-fEKnzZ/src/GameActionHandler.cpp (362): GameActionHandler::update(std::function<void ()>)
/tmp/factorio-build-fEKnzZ/src/MainLoop.cpp (1340): MainLoop::gameUpdateStep(MultiplayerManagerBase*, Scenario*, AppManager*, MainLoop::HeavyMode)
/tmp/factorio-build-fEKnzZ/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-fEKnzZ/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
0x7fcce3578111
0x7fcce35f68f7
0xffffffffffffffff
Stack trace logging done
 294.670 Error CrashHandler.cpp:190: Map tick at moment of crash: 5152754
 294.670 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.
 304.607 Uploading log file
 304.669 Info SystemUtil.cpp:871: Started /home/pc/Games/Factorio/factorio_2.0/bin/x64/factorio; trampoline PID: 161005

What did I do?

I loaded a saved game to which I added my mod. Using the commands at the top of the log file, I verified that there is a valid entity on game.surfaces.minime_character_previews_character. I then opened the "storage" tab of gvv and went to a table that contained a reference to that LuaEntity. Right-clicking on the entry resulted in the crash.

5 days ago

Thanks for report. I think it is better to report software crashes at bug report forum.
https://forums.factorio.com/viewforum.php?f=7

with savefile and stages to reproduce.
Modders may can make an exception but it is better to make developers to know it rather than hiding.

"hiding" = modder make exception and say nothing to factorio developer.

4 days ago

Thanks for report. I think it is better to report software crashes at bug report forum.

Here is the bug report. FWIW, I've found out that the crash will occur only if LuaEntity is of type 'character' and if that character is not connected to a player.

4 days ago

Thank you very much.

4 days ago

And it's already fixed for the next version! :-)

New response