Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 703386 - games-roguelike/dwarf-fortress-0.44.12 program hangs after quitting
Summary: games-roguelike/dwarf-fortress-0.44.12 program hangs after quitting
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Gentoo Games
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2019-12-20 00:23 UTC by FSK1153
Modified: 2022-07-06 08:39 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix for df-0.44.12 getting stuck in a loop on quit (df_enabler.patch,425 bytes, patch)
2022-05-01 13:16 UTC, Martin Doucha
Details | Diff
Fix for df-0.44.12 getting stuck in a loop on quit (df_enabler.patch,286 bytes, patch)
2022-05-04 19:40 UTC, Martin Doucha
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description FSK1153 2019-12-20 00:23:09 UTC
Unstable testing build for dwarf fortress soft locks upon exiting instead of closing properly.

Reproducible: Always

Steps to Reproduce:
1.Open the game
2.Close the game via quit
3.Find the game and force kill it with PID.
Actual Results:  
Game window becomes unresponsive. Terminal command of which the game was launched returns this:
New window size: 640x300
Font size: 8x12
Resizing grid to 80x25
Resizing font to 8x12

New window size: 640x300
Font size: 8x12
Resizing grid to 80x25
Resizing font to 8x12

New window size: 640x300
Font size: 8x12
Resizing grid to 80x25
Resizing font to 8x12

until killed manually.

Expected Results:  
Game terminates cleanly.

Gentoo linux 17.1 amd64 no mutilib
Kernel: 4.19.72
wm:Ice-wm 1.5.5
CPU: Intel Core i5-4300U
Ram: 11677 Mb
Terminal emulator: RXVT-Unicode


Please ask me for more information. I am not familar with gentoo/linux.
Comment 1 Rick Foland 2020-05-12 14:27:17 UTC
I also have this problem on KDE Plasma. The problem persists with version 0.47.04 as well.
Comment 2 wolfgang 2021-05-06 13:16:37 UTC
I can confirm this behaviour on amd64, including the revbump I'm working on in [PR 20534][1]

I've taken a few steps to try to find a root cause, and I thought it'd be worthwhile to document my findings here:

- Based on stepping through the code with gbd, the issue appears to originate from  g_src/enabler.cpp . Specifically, I've observed the following:
    1. main() is entered (line 712) when the program is started
    2. the main loop, enablerst::loop() is called from main() on line 796
    3. the main loop eventually enters either an ncurses loop (line 582) or SDL loop (line 586)
    4. Whichever loop was entered, it ultimately exits succesfully whenever "exit" is selected from the main menu
    5. endroutine() appears to be a noop
    6. Finally, the renderer is deleted as the last line in the main loop, line 592

This is where things get really weird, and has me scratching my head. As far as I can tell from the logic in main() and enablerst::loop(), the next thing that should happen is line 798 should be executed.

However, instead, the code loops back to line 555 in the enablerst::loop() function. I can't for the life of me figure out why this is the case. I'm thinking it may have something to do with the multithreading stuff set up earlier in main(), but I'm not entirely sure.

The next thing I did is start to work backwards to try to determine which version of dwarf fortress this started on.

I've gotten as far back as 0.40.24, where instead of an endless loop, the game segfaults. I find this encouraging because at least it is different behaviour.

The next things I intend to try are:

1. diff between 0.40.24 and 0.42.06 g_src directories to see what (if anything) is different
2. uhm, maybe step through the assembly code?!?! I've never done this before but it might be fun
3. keep moving backwards until I find one that actually works properly

I should note: I tested this using the bundled libgraphics.so and was unable to reproduce the error, which suggests that perhaps the release tarball does not contain the same code as upstream. Unfortunately since the code is closed-source there's no way to investigate that further. I could maybe reach out to toady on a forum or something, but I'm not sure how respnsive he is to these sorts of things.

[1]: https://github.com/gentoo/gentoo/pull/20534
Comment 3 Martin Doucha 2022-05-01 13:16:14 UTC
Created attachment 775772 [details, diff]
Fix for df-0.44.12 getting stuck in a loop on quit

It's not really a code change but rather GCC optimizations going nuts on broken code. When you add "return 0;" at the end of enablerst::loop(), the problem goes away.
Comment 4 Martin Doucha 2022-05-04 19:40:02 UTC
Created attachment 776771 [details, diff]
Fix for df-0.44.12 getting stuck in a loop on quit

Small improvement to the previous patch: drop the pointless end-of-file newline hunk.

BTW, the patch also applies cleanly to DF v0.47.05.
Comment 5 Larry the Git Cow gentoo-dev 2022-07-06 08:39:05 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=97a24df3591ca7bebd0fcd189e1da5f16240715c

commit 97a24df3591ca7bebd0fcd189e1da5f16240715c
Author:     Joshua Goins <josh@redstrate.com>
AuthorDate: 2022-06-28 23:57:28 +0000
Commit:     Ionen Wolkens <ionen@gentoo.org>
CommitDate: 2022-07-06 08:37:53 +0000

    games-roguelike/dwarf-fortress: add 0.47.05
    
    Signed-off-by: Joshua Goins <josh@redstrate.com>
    Co-authored-by: Sven Eusewig <sveneusewig@yahoo.de>
    Co-authored-by: Wolfgang E. Sanyer <ezzieyguywuf@gmail.com>
    Closes: https://bugs.gentoo.org/703384
    Closes: https://bugs.gentoo.org/703386
    Closes: https://bugs.gentoo.org/717752
    Closes: https://bugs.gentoo.org/729002
    Signed-off-by: Ionen Wolkens <ionen@gentoo.org>

 games-roguelike/dwarf-fortress/Manifest            |  2 +
 .../dwarf-fortress/dwarf-fortress-0.47.05.ebuild   | 97 ++++++++++++++++++++++
 .../files/dwarf-fortress-0.47.05-fix-cmath.patch   | 11 +++
 ...warf-fortress-0.47.05-segfault-fix-729002.patch | 49 +++++++++++
 4 files changed, 159 insertions(+)