possible crash in `autofarm`
copied from steam discussions
Every time I start a fortress and then exit the game and try to load it it crashes. It has something to do with autofarm plugin? Anyone can tell me what is wrong or how to fix it?
Version 53.03
Received signal 22 SIGABRT
0> Dwarf_Fortress+0xAAC0F6
1> Dwarf_Fortress+0xAAC25F
2> ucrtbase!raise+0x1D9
3> ucrtbase!abort+0x31
4> ucrtbase!terminate+0x1E
5> ucrtbase!_C_specific_handler_noexcept+0x4A
6> ntdll!_chkstk+0x9F
7> ntdll!RtlLocateExtendedFeature+0x597
8> ntdll!RtlRaiseException+0x221
9> KERNELBASE!RaiseException+0x8A
10> VCRUNTIME140!CxxThrowException+0x97
11> dfhooks_dfhack!DFHack::PersistentDataItem::ival+0xAF
12> autofarm_plug+0x10EEC
13> autofarm_plug!plugin_enable+0x52
14> dfhooks_dfhack!DFHack::PluginManager::reloadAll+0x4EB
15> dfhooks_dfhack!DFHack::Core::runCommand+0xCCF
16> dfhooks_dfhack!DFHack::Core::runCommand+0x15C
17> dfhooks_dfhack!DFHack::Core::loadScriptFile+0x865
18> dfhooks_dfhack!DFHack::Core::loadScriptFile+0xD28
19> dfhooks_dfhack!DFHack::Core::handleLoadAndUnloadScripts+0x5B8
20> dfhooks_dfhack!DFHack::Core::onStateChange+0x1068
21> dfhooks_dfhack!DFHack::Core::doUpdate+0x380
22> dfhooks_dfhack!DFHack::Core::Update+0xB3
23> dfhooks!dfhooks_update+0x975E
24> Dwarf_Fortress+0x8BFD9B
25> Dwarf_Fortress+0x8C1249
26> SDL2!SDL_DYNAPI_entry+0x799D7
27> SDL2!SDL_DYNAPI_entry+0x12EEDE
28> ucrtbase!wcsrchr+0x150
29> KERNEL32!BaseThreadInitThunk+0x17
30> ntdll!RtlUserThreadStart+0x2C
I looked at this and can't reproduce.
I will mention that if ival() is throwing an uncaught exception it should probably print to a log file and preferably (assuming dfhack state is borked) also use SDL messagebox to provide some context to make it easier for people to report.
I'm not sure if it's feasible, but saving their game somewhere might be nice too as dfhack should never cause progress to be lost no matter what state it's in.
And of course, PersistentDataItem has no way to know if there's a catcher for the exception.
Maybe its throwing methods should be wrapped in try - catch by the plugin, and plugin subsequently disabled.
It's clearly a throw of some sort, and there are some things in PersistentDataitem that can throw, but i wasn't able to come up with an idea of what
it's possible that this is due to DF data shotgun corruption
maybe we should use try-catch on plugin invocations and disable the plugin if the plugin throws an exception?