Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash on world load in DFHack::Translation::TranslateName #3820

Closed
paudley opened this issue Sep 28, 2023 · 9 comments · Fixed by #3824
Closed

crash on world load in DFHack::Translation::TranslateName #3820

paudley opened this issue Sep 28, 2023 · 9 comments · Fixed by #3824

Comments

@paudley
Copy link

paudley commented Sep 28, 2023

The world is playable without DFHack but with DFHack loaded, it segfaults just after the loading screen for the save finishes and before the fort is displayed.

Happy to help troubleshoot this anyway I can.

Here's the backtrace from gdb. (linux install, 50.10r1)

#0  0x00007fffedd9061b in DFHack::Translation::TranslateName[abi:cxx11](df::language_name const*, bool, bool) () from hack/libdfhack.so
#1  0x00007fffedb012b5 in df::function_identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (*)(df::language_name const*, bool, bool)>::invoke(lua_State*, int) () from hack/libdfhack.so
#2  0x00007fffedadd3be in meta_call_function(lua_State*) () from hack/libdfhack.so
#3  0x00007ffff0b50a1d in luaD_precall(lua_State*, lua_TValue*, int) () from hack/liblua.so
#4  0x00007ffff0b6c6f5 in luaV_execute(lua_State*) () from hack/liblua.so
#5  0x00007ffff0b50cc8 in luaD_callnoyield(lua_State*, lua_TValue*, int) () from hack/liblua.so
#6  0x00007ffff0b513c9 in luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long) () from hack/liblua.so
#7  0x00007ffff0b45296 in lua_pcallk(lua_State*, int, int, int, long, int (*)(lua_State*, int, long)) () from hack/liblua.so
#8  0x00007fffedae3011 in DFHack::Lua::SafeCall(DFHack::color_ostream&, lua_State*, int, int, bool) () from hack/libdfhack.so
#9  0x00007fffedae7197 in DFHack::Lua::RunCoreQueryLoop(DFHack::color_ostream&, lua_State*, bool (*)(DFHack::color_ostream&, lua_State*, void*), void*) () from hack/libdfhack.so
#10 0x00007fffedaa0316 in DFHack::Core::runCommand(DFHack::color_ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) () from hack/libdfhack.so
#11 0x00007fffedaa0e22 in DFHack::Core::runCommand(DFHack::color_ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from hack/libdfhack.so
#12 0x00007fffedaf7862 in internal_runCommand(lua_State*) () from hack/libdfhack.so
#13 0x00007ffff0b50a1d in luaD_precall(lua_State*, lua_TValue*, int) () from hack/liblua.so
#14 0x00007ffff0b6c94d in luaV_execute(lua_State*) () from hack/liblua.so
#15 0x00007ffff0b50cc8 in luaD_callnoyield(lua_State*, lua_TValue*, int) () from hack/liblua.so
#16 0x00007ffff0b513c9 in luaD_pcall(lua_State*, void (*)(lua_State*, void*), void*, long, long) () from hack/liblua.so
#17 0x00007ffff0b45296 in lua_pcallk(lua_State*, int, int, int, long, int (*)(lua_State*, int, long)) () from hack/liblua.so
#18 0x00007fffedae3011 in DFHack::Lua::SafeCall(DFHack::color_ostream&, lua_State*, int, int, bool) () from hack/libdfhack.so
#19 0x00007fffedae7197 in DFHack::Lua::RunCoreQueryLoop(DFHack::color_ostream&, lua_State*, bool (*)(DFHack::color_ostream&, lua_State*, void*), void*) () from hack/libdfhack.so
#20 0x00007fffedaa0316 in DFHack::Core::runCommand(DFHack::color_ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) () from hack/libdfhack.so
#21 0x00007fffedaa0e22 in DFHack::Core::runCommand(DFHack::color_ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from hack/libdfhack.so
#22 0x00007fffedaa1602 in DFHack::Core::loadScriptFile(DFHack::color_ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool) () from hack/libdfhack.so
#23 0x00007fffedaa1daa in loadScriptFiles(DFHack::Core*, DFHack::color_ostream&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from hack/libdfhack.so
#24 0x00007fffedaa24ed in DFHack::Core::handleLoadAndUnloadScripts(DFHack::color_ostream&, DFHack::state_change_event) () from hack/libdfhack.so
#25 0x00007fffedaa437c in DFHack::Core::onStateChange(DFHack::color_ostream&, DFHack::state_change_event) () from hack/libdfhack.so
#26 0x00007fffedaa4d91 in DFHack::Core::doUpdate(DFHack::color_ostream&) () from hack/libdfhack.so
#27 0x00007fffedaa6879 in DFHack::Core::Update() () from hack/libdfhack.so
#28 0x00007ffff7a5ea80 in enablerst::async_loop() () from /home/paudley/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/Dwarf Fortress/libg_src_lib.so
#29 0x00007ffff7a5f2d4 in call_loop(void*) () from /home/paudley/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/Dwarf Fortress/libg_src_lib.so
#30 0x00007ffff778ba91 in RunThread.lto_priv.0 () from /usr/lib64/libSDL2-2.0.so.0
#31 0x00007ffff6e91259 in ?? () from /lib64/libc.so.6
#32 0x00007ffff6f2661c in ?? () from /lib64/libc.so.6
@paudley
Copy link
Author

paudley commented Sep 28, 2023

Note, this world was created with DFHack on, it's only on subsequent save and load that it crashes.

@lethosor
Copy link
Member

Can you upload the save (and mods it uses)? e.g. to https://dffd.bay12games.com/, or here if it fits.

@paudley
Copy link
Author

paudley commented Sep 28, 2023

https://dffd.bay12games.com/file.php?id=16856

I've included the save folder as well as the entire mods directory. (Note sure what the best way to include mods is). If you need a list of the active mods, I can probably grab the new mod manager files from dfhack and send that over.

@lethosor
Copy link
Member

I think your archive is missing at least one mod, the "Living Gods" mod:
image

@paudley
Copy link
Author

paudley commented Sep 28, 2023

I've reuploaded it as 3820_2.tar.bz2 which contains save/region2 and data/installed_mods. Looking at the mod list it seems to contain all the mods I've jammed in there.

@lethosor
Copy link
Member

Reproduced, thanks. I was able to put all of those mods in the mods directory and it picked the right ones up.

@paudley
Copy link
Author

paudley commented Sep 28, 2023

Sweet! Thanks, let me know if there is anything else I can to do help. DFHack makes my DF games SO much better!

@lethosor
Copy link
Member

lethosor commented Sep 28, 2023

There is a satyr named "Sazir Dalzat" with a seemingly-invalid name about 3/4 of the way down the u -> livestock list, which causes warn-starving to crash in TranslateName(). I'm not sure if this is due to save corruption, playing with DFHack, a broken mod, or some other reason. Do any of those sound likely to you? Have you interacted with this satyr in any way before?

image

Specifically, unit.name.words[1] is 4192, but unit.name.language is 0, and language 0 (DWARF) has only 2380 valid words. Actually, all languages have only 2380 valid words, except the last language, #8 (GEN_DIVINE), which has 0 words, but 4576 items in unknown1/unknown2. DF evidently is not using these, because if I set words[1] to a valid value (like 2000), DF does pull that word from the DWARF language.

[lua]# ~unit.name.words
<int32_t[]: 0x7fff49d5a818>
FrontCompound          	 = 1512
RearCompound           	 = 4192
FirstAdjective         	 = -1
SecondAdjective        	 = -1
HyphenCompound         	 = -1
TheX                   	 = -1
OfX                    	 = -1

[lua]# ~world.raws.language.translations[8].unknown1[4192]
<string: 0x7fff821f8600>
value                  	 = URGE
[lua]# ~world.raws.language.translations[8].unknown2[4192]
<string: 0x7fff821f8630>
value                  	 = kiagiang

4192 looks suspiciously close to a power of two in decimal form (8192 - 4000) but not so close in hex.

DF appears to ignore the 4192 entirely; "dalzat" is word 1512.

GDB output for reference:

#2  0x00007ffff7a8dc76 in DFHack::Translation::TranslateName[abi:cxx11](df::language_name const*, bool, bool) (name=0x7fff49d5a7d8, inEnglish=false, onlyLastPart=false)
    at modules/Translation.cpp:171
171	                word.append(*world->raws.language.translations[name->language]->words[name->words[1]]);
(gdb) p name.words
$8 = {1512, 4192, -1, -1, -1, -1, -1}
(gdb) p name.words[1]
$9 = 4192
(gdb) p (*((*world)->raws.language.translations[0])).words.size()
$10 = 2380
(gdb) p name
$11 = (const df::language_name *) 0x7fff49d5a7d8
(gdb) p *name
$12 = {first_name = "sazir", nickname = "", words = {1512, 4192, -1, -1, -1, -1, -1}, parts_of_speech = {df::enums::part_of_speech::VerbPassive, df::enums::part_of_speech::Verb, 
    df::enums::part_of_speech::Noun, df::enums::part_of_speech::Noun, df::enums::part_of_speech::Noun, df::enums::part_of_speech::Noun, df::enums::part_of_speech::Noun}, language = 0, 
  type = df::enums::language_name_type::Figure, has_name = true}

@paudley
Copy link
Author

paudley commented Sep 28, 2023

So that must be one of the mods, several add or have language tags in them. This world has just a few in game days of play so I suspect it's a mod issue. Thanks for the quick troubleshooting. I'll see if I can hunt down the offending mod and ping the author. Have a great night!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants