View Issue Details

IDProjectCategoryView StatusLast Update
0012835Dwarf FortressAdventure Mode -- Generalpublic2024-06-25 23:26
ReporterDFAdventurer Assigned To 
PriorityhighSeveritycrashReproducibilityalways
Status newResolutionopen 
PlatformPCOSWindows 11 ProOS Version23H2
Summary0012835: Adventure Mode Crash When Entering Or Exiting Necro Tower DF v. 51.01-beta13
DescriptionI am playing as a male dwarf vampire. I used dice to acquire vampirism. There is a necro tower in my world which has a polarbear woman overlord. I have experienced a crash 4 times in a row at this specific site. It occurs when I enter or exit the tower's main entrance. There are 4 or 5 dwarf necromancers at the site as well as 3 or 4 undead elves. There are a couple of dozen books inside the tower including a book that once read gives the necro abilities.

I'm playing on an above average PC with an Intel i9 20x core processor, 128GB ram, powerful AMD video card.
Steps To ReproduceCrash 1 (occurred once)
Travel to necro tower location.
Zoom into character view.
Attempt to enter tower. Crash to desktop occurs.

Crash 2 (occurred 3 times )
Travel to necro tower location.
Zoom into character view.
Enter necro tower. Interact with inhabitants.
Attempt to exit tower.
Once outside the door way crash to desktop occurs.
Additional InformationCrash Log (occurred while entering tower):
0> Dwarf_Fortress!std::_Init_locks::operator=+0x93F536
1> Dwarf_Fortress!std::_Init_locks::operator=+0x93F6A9
2> KERNELBASE!UnhandledExceptionFilter+0x1EC
3> ntdll!memcpy+0x2BBD
4> ntdll!_C_specific_handler+0x97
5> ntdll!_chkstk+0x12F
6> ntdll!RtlFindCharInUnicodeString+0xA96
7> ntdll!KiUserExceptionDispatcher+0x2E
8> fmod!FMOD_System_Update+0x5D64
9> fmod!FMOD::ChannelControl::setLowPassGain+0x45
10> Dwarf_Fortress!std::_Init_locks::operator=+0x3F7AAF
11> Dwarf_Fortress!std::_Init_locks::operator=+0x696757
12> Dwarf_Fortress!std::_Init_locks::operator=+0x69F974
13> Dwarf_Fortress!std::_Init_locks::operator=+0x69FCF5
14> overlay_plug+0x8A3E
15> Dwarf_Fortress!std::_Init_locks::operator=+0xA4F6A5
16> Dwarf_Fortress!std::_Init_locks::operator=+0x772334
17> Dwarf_Fortress!std::_Init_locks::operator=+0x773669
18> SDL2!SDL_DYNAPI_entry+0x799D7
19> SDL2!SDL_DYNAPI_entry+0x12EEDE
20> ucrtbase!recalloc+0xA3
21> KERNEL32!BaseThreadInitThunk+0x1D
22> ntdll!RtlUserThreadStart+0x28
Tags64-bit OS, crash, necro tower, vampire dwarf

Activities

Entity-36572-B

2024-06-19 16:26

reporter   ~0042258

I just experienced this as well, on the beta branch. Also at a tower site, but with all local buildings not just the tower itself. Going inside seems to be fine, but going back out or going out and immediately in again causes a crash. I did notice a spike in lag when the amount of visible tiles shot up in the doorway right before the crash; probably related.
I am playing as a regular moth woman with a pet horse parked nearby. The crash also occured with buildings that have no doors.

Vitamin

2024-06-25 21:52

reporter   ~0042262

Last edited: 2024-06-25 21:59

I have the exact same problem, with the very latest 51.01-beta18.

I'm attaching a save file that you can load, where I'm standing right in front of a necromancer building. You can go in and out of the building to trigger the crash.

I suspect it has to do with the new necromancer tower specific audio files or something, transitioning between buildings, maybe a filename typed in wrong in the code.
data/sound/audio/ambiance/regions/necromancer-tower/base.ogg and neutral.ogg
They seem to be new additions to this update, if I'm not mistaken, and the audio library fmod.dll is near the top of the stack trace.

NOTE: Please ignore the, uh, three Faint Corpses who are surprisingly emotional and intelligent that are following me around. The crash was happening with or without them. Also, they like to randomly disappear, but that's not a bug, it's just them Vanishing TM.

Vitamin

2024-06-25 21:53

reporter   ~0042263

Last edited: 2024-06-25 23:26

This is why I think the crash is in fmod:

7> ntdll!KiUserExceptionDispatcher+0x2E
8> fmod!FMOD_System_Update+0x5D64
9> fmod!FMOD::ChannelControl::setLowPassGain+0x45

My intuition is that it could be an over-release of the sound that is supposed to transition out when you exit the necromancer building. If that sound is already being released internally by fmod.dll then if you manually release it in your code it could trigger a crash similar to https://qa.fmod.com/t/system-update-crash/14026/4 This could be tied to a race condition since fmod's System::update() function is not thread-safe. Make sure you’re calling it from the same thread as other FMOD commands.

I notice for the necro tower you have implemented a cool low pass filter that is applied when you're inside the tower and taken back off when you walk outside. However there is a lag between when the frame is rendered and when the change to the audio effects actually happen. The audio effect changes happen around the same time that the changes to the shadows are rendered. However, if you go very fast in or out of one of these buildings, it seems that you incur multiple quick successive calls to change the low pass filter, likely resulting in too many successive System::update() calls to FMOD, which will cause an over-release or race condition.

This aligns with the fact the issue doesn't happen every time and could happen either when exiting, or entering the building, or when stepping to the square right before leaving, since the spatial audio triggers the distance effect as you get closer, not just when you fully leave or enter.

While clearly this has to do with threading, turning off multithreading doesn't fix it.

Note: the crash can be completely avoided by stepping very slowly in and out of the necro buildings using arrow keys to move just one square at a time, then waiting about 5-10 seconds until the audio low pass filter effect has been fully applied and stabilized. That gives the low pass filter/spatialization effect time to get fully mixed in.

Yet the crash happens 100% reliably when clicking such that your the character moves lots of steps very quickly. You can hear audio pops before the crash. Sometimes you hear the pops even when stepping slowly, so clearly there is something to be fine-tuned here.

Overall the new audio effect is very nice, so it will be certainly worth fixing this threading issue. While it's only been reported for necro towers, I suspect anywhere that you're applying a similar effect fade in/out when entering or exiting an area could cause this crash. You can probably fix in a number of ways: conditional mutex, debounce timer, or atomic flag with spinlock. RxCPP could be a more scalable solution though if you are having to do a lot of this.

Also if I'm right, let me know if you're hiring, I could help you port to Mac.

Vitamin

2024-06-25 21:56

reporter   ~0042264

Here is the save file to reproduce the issue: https://drive.google.com/file/d/1fAVeQOSB8HVPIVoc1xAJZ3e8_39X_S7U/view?usp=drive_link

For extra fun, visit the fortress of Godlyluck in there and figure out how to make the game not run at like 2 FPS.

Add Note

Note

Issue History

Date Modified Username Field Change
2024-04-25 06:20 DFAdventurer New Issue
2024-04-25 06:20 DFAdventurer Tag Attached: 64-bit OS
2024-04-25 06:20 DFAdventurer Tag Attached: crash
2024-04-25 06:20 DFAdventurer Tag Attached: necro tower
2024-04-25 06:20 DFAdventurer Tag Attached: vampire dwarf
2024-06-19 16:26 Entity-36572-B Note Added: 0042258
2024-06-25 21:52 Vitamin Note Added: 0042262
2024-06-25 21:53 Vitamin Note Added: 0042263
2024-06-25 21:56 Vitamin Note Added: 0042264
2024-06-25 21:59 Vitamin Note Edited: 0042262
2024-06-25 22:09 Vitamin Note Edited: 0042263
2024-06-25 22:10 Vitamin Note Edited: 0042263
2024-06-25 22:11 Vitamin Note Edited: 0042263
2024-06-25 22:35 Vitamin Note Edited: 0042263
2024-06-25 22:49 Vitamin Note Edited: 0042263
2024-06-25 23:12 Vitamin Note Edited: 0042263
2024-06-25 23:26 Vitamin Note Edited: 0042263
2024-06-25 23:26 Vitamin Note Edited: 0042263