dfhack
dfhack copied to clipboard
`enable title-folder` in init file freezes on start in Windows
Putting enable title-folder anywhere in the init file freezes the game after the two grand notes at the beginning of the intro movies. This only occurs on Windows, which I'm only using because I temporarily have to for complicated reasons.
I can confirm this. The main thread hangs in _SDL_SemWait. At the same time, another thread is waiting in DFHack::Core::Update because that thread called SDL_NumJoysticks. And a third thread (the one executing run_dfhack_init) is waiting in _SDL_WM_SetCaption.
Basically we're getting a mutex deadlock, presumably because a thread other than the main thread called SDL_NumJoysticks, causing an expectation violation with respect to DFHack::Core::getInstance().
I'm not sure what's going on in SDL_NumJoysticks:
{
DFHack::Core & c = DFHack::Core::getInstance();
return c.Update();
}
This makes SDL_NumJoysticks unsafe unless called from the main thread, which appears to be what is happening here.
(Update: d'oh, I forgot that SDL_NumJoysticks is our "toe in the door".)
I can probably get more information on who is calling what when, but I'll have to use ghidra's debugger instead of MSVC's because MSVC is perversely not letting me see call stack details for stack trace locations it doesn't have source for. Ghidra's debugger is, however, far more user-hostile than MSVC's, so I'm only going to do that if it's absolutely necessary.