Segfault on fresh start
Describe the bug
Freshly downloaded experimental crashes on launch
Attach save file
N/A
Steps to reproduce
- Download cdda-linux-tiles-x64-2024-08-19-0749.tar.gz
- Extract
- Change nothing, go straight for the launcher
- Segfault
Expected behavior
Game would launch.
Screenshots
No response
Versions and configuration
Void Linux, build x64-2024-08-19-0749, tiles Can't get to the main menu and didn't change anything manually prior to launch
Additional context
PS. Before this had a build from last month, it works fine
I can confirm this, crashes straight up on game start before anything is drawn. Looks imgui related based on the stack trace.
I can confirm this, crashes straight up on game start before anything is drawn. Looks imgui related based on the stack trace.
Language selector is supposed to be shown on first launch, i assume it is managed by imgui now and doesn't work?
Worked around this by copying the config dir from older build. The game doesn't crash if a language is already set.
So IDK why, but just deleting the call to select_language() is enough to get through this issue and enter the main menu correctly. Something later must be initializing some kind of state that select_language depends on.
+++ b/src/main.cpp
@@ -851,8 +851,7 @@
#if defined(LOCALIZE)
if( get_option<std::string>( "USE_LANG" ).empty() && !SystemLocale::Language().has_value() ) {
- const std::string lang = select_language();
diff --git a/src/third-party/imgui/imgui.cpp b/src/third-party/imgui/imgui.cpp
--- a/src/third-party/imgui/imgui.cpp
+++ b/src/third-party/imgui/imgui.cpp
@@ -5093,6 +5093,9 @@
text_display_end = text_end;
ImFont* font = g.Font;
+ if (!font) {
+ font = GetDefaultFont();
+ }
const float font_size = g.FontSize;
if (text == text_display_end)
return ImVec2(0.0f, font_size);
this is enough to stop the crash, but the language selection menu a) doesn't render until a keystroke is entered, and b) renders all fucky anyway. But I'm not testing on a fully up to date master so I need to recheck if that's still the case.
Font gets set in ImGui::NewFrame() to the result of GetDefaultFont(), but honestly if there isn't already a font chosen then the default isn't any worse than anything else.
This is what I get after one keystroke with that diff. @db48x IDK if that's tracked in a separate issue or relevant to this particular codepath happening 'pre main menu'.
Interestingly the tiles build actually renders the menu correctly.
diff --git a/src/third-party/imgui/imgui.cpp b/src/third-party/imgui/imgui.cpp --- a/src/third-party/imgui/imgui.cpp +++ b/src/third-party/imgui/imgui.cpp @@ -5093,6 +5093,9 @@ text_display_end = text_end; ImFont* font = g.Font; + if (!font) { + font = GetDefaultFont(); + } const float font_size = g.FontSize; if (text == text_display_end) return ImVec2(0.0f, font_size);this is enough to stop the crash
I wouldn’t make this change here in imgui.cpp. Instead, make sure that cataimgui::client::load_fonts is called early enough.
, but the language selection menu a) doesn't render until a keystroke is entered, and b) renders all fucky anyway. But I'm not testing on a fully up to date master so I need to recheck if that's still the case.
From your screenshot you are using ImTui, which either has problems or we’re using incorrectly. Or both! I haven’t looked into it yet, but I believe a separate bug has already been filed.
Oh, and two other people have mentioned that their menus also show up blank until they press a key or get the mouse involved, but I haven’t even been able to reproduce that.
Yes, sorry. The messy menu was from imtui (I thought maybe the crash was im_gui_ related). But it happens in both builds. And it only renders okay in imgui.
I will play with reordering the fontloader call, thanks for that tip.
I wouldn’t make this change here in imgui.cpp. Instead, make sure that
cataimgui::client::load_fontsis called early enough.
So load_fonts is called in catacurses::init_interface(); which happens on line 781 https://github.com/CleverRaven/Cataclysm-DDA/blob/2db2a2ea1991860928044b75c8e1885d9b391ef2/src/main.cpp#L781. The crashing call to select_language is on line 854, which is well after that. So either the init call is happening too early (?) or something else is up.
select_language doesn't crash if called after main_menu::opening_screen so clearly init_interface() isn't initting enough.