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

Segfault on fresh start #75818

Closed
risusinf opened this issue Aug 19, 2024 · 11 comments · Fixed by #76070
Closed

Segfault on fresh start #75818

risusinf opened this issue Aug 19, 2024 · 11 comments · Fixed by #76070
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes. ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds (S2 - Confirmed) Bug that's been confirmed to exist

Comments

@risusinf
Copy link

risusinf commented Aug 19, 2024

Describe the bug

Freshly downloaded experimental crashes on launch

Attach save file

N/A

Steps to reproduce

  1. Download cdda-linux-tiles-x64-2024-08-19-0749.tar.gz
  2. Extract
  3. Change nothing, go straight for the launcher
  4. 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

crash.log

PS. Before this had a build from last month, it works fine

@risusinf risusinf added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Aug 19, 2024
@Karol1223 Karol1223 added the <Crash / Freeze> Fatal bug that results in hangs or crashes. label Aug 19, 2024
@harakka
Copy link
Member

harakka commented Aug 23, 2024

I can confirm this, crashes straight up on game start before anything is drawn. Looks imgui related based on the stack trace.

@harakka harakka added (S2 - Confirmed) Bug that's been confirmed to exist ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Aug 23, 2024
@risusinf
Copy link
Author

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?

@strategictraveler
Copy link
Contributor

Worked around this by copying the config dir from older build. The game doesn't crash if a language is already set.

@akrieger
Copy link
Member

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();

@akrieger
Copy link
Member

akrieger commented Aug 25, 2024

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.

@akrieger
Copy link
Member

akrieger commented Aug 25, 2024

image

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'.

@akrieger
Copy link
Member

Interestingly the tiles build actually renders the menu correctly.
Screenshot 2024-08-24 at 9 33 29 PM

@db48x
Copy link
Contributor

db48x commented Aug 25, 2024

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.

@akrieger
Copy link
Member

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.

@akrieger
Copy link
Member

I wouldn’t make this change here in imgui.cpp. Instead, make sure that cataimgui::client::load_fonts is called early enough.

So load_fonts is called in catacurses::init_interface(); which happens on line 781

catacurses::init_interface();
. 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.

@akrieger
Copy link
Member

select_language doesn't crash if called after main_menu::opening_screen so clearly init_interface() isn't initting enough.

db48x pushed a commit to db48x/Cataclysm-DDA that referenced this issue Aug 31, 2024
and then start and end a frame so that things work correctly.

Fixes CleverRaven#75818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes. ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants