Menu

#109 ltris2: segmentation fault on launch (GNOME/Wayland on openSUSE Tumbleweed)

None
closed-fixed
None
5
2024-09-03
2024-07-31
Atri
No

Big thanks, as a long time player of ltris I am really keen on trying the updated ltris2. Tried to build this on openSUSE and faced a couple of problems, one easily fixed and the other fatal. This bug is about the latter, so here it goes first.

Segmentation fault

When launching ltris2, on my GNOME/Wayland system, it simply crashes. Here is the output I see on the terminal (you will also see the issue with CONFIGDIR that I mention below, but I do not think that directly relates to the crash itself):

Initializing SDL
Loading configuration /home/badshah//.local/share/ltris2/ltris2.conf
ERROR: tools.cpp:52: FileParser(): Could not open /home/badshah//.local/share/ltris2/ltris2.conf
---
ltris2 2.0
Copyright 2024 Michael Speck
Published under GNU GPL
---
No permission to access global highscores
Falling back to /home/badshah/~/.local/share/ltris2/ltris2.hscr
No hiscores file /home/badshah/~/.local/share/ltris2/ltris2.hscr yet
Mixer opened (16 channels, 1024 buf size)
No game controller found...
Initializing view (theme=Standard, fullscreen=1)
Creating window with size 3840x2160 (fullscreen)
Loading theme /usr/share/ltris2/themes/Standard
Initializing game (type=-1)
Segmentation fault (core dumped)

I was able to get a gdb backtrace that indicates, in part (full bt attached):

Thread 1 (Thread 0x7ffff65218c0 (LWP 30411) "ltris2"):
#0  0x0000555555572ea1 in tetris_recreate_bkgnd (id=1) at ../libgame/tetris.c:188
#1  tetris_init () at ../libgame/tetris.c:361
#2  VGame::init (this=0x7fffffffd008, _type=<optimized out>) at /usr/src/debug/ltris2-2.0/src/vgame.cpp:225
#3  0x00005555555669c1 in View::init (this=this@entry=0x7fffffffced0, t="Standard", f=f@entry=1, reinit=reinit@entry=false) at /usr/src/debug/ltris2-2.0/src/view.cpp:107
#4  0x000055555556ac2f in View::View (this=<optimized out>, this=<optimized out>) at /usr/src/debug/ltris2-2.0/src/view.cpp:66
#5  0x000055555555c24f in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/ltris2-2.0/src/main.cpp:52

when the game is launched.

Other (minor) issues

No-op functions with non-void return

There are a few NOOP functions without return values but declared as non-void. These lead to compilation errors with -Werror=return-type (part of the default build flags for GCC 13, I understand). Or, we could build with -Wno-error=return-type forced into the CFLAGS but fixing these seems like the better option to me.

---
 libgame/sdl.c |    3 +++
 1 file changed, 3 insertions(+)

Index: ltris2-2.0/libgame/sdl.c
===================================================================
--- ltris2-2.0.orig/libgame/sdl.c
+++ ltris2-2.0/libgame/sdl.c
@@ -337,6 +337,7 @@ void set_surf_clip( SDL_Surface *surf, i
 /* set pixel */
 Uint32 set_pixel( SDL_Surface *surf, int x, int y, int pixel )
 {
+   return 0;
 }

 /* get pixel */
@@ -567,6 +568,7 @@ void undim_screen(int steps, int delay,
 */
 int wait_for_key()
 {
+   return 0;
 }

 /*
@@ -602,6 +604,7 @@ void flip_screen()
 /* creates cursor */
 SDL_Cursor* create_cursor( int width, int height, int hot_x, int hot_y, char *source )
 {
+   return NULL;
 }

 /*

Invalid hiscore file paths when CONFIGDIR has a leading ~

There are also some problems with paths involving CONFIGDIR when the leading char is ~, notably as in the default value. When the user does not have permissions to write to /var/FOO where the system hiscores are stored, it tries to write/read them from the defined CONFIGDIR. If the value of this variable has a leading ~, this sets the hiscore paths incorrectly:

No permission to access global highscores
Falling back to /home/badshah/~/.local/share/ltris2/ltris2.hscr
No hiscores file /home/badshah/~/.local/share/ltris2/ltris2.hscr yet

Note that /home/badshah/~/.local/share/ltris2/ is an invalid path. It should probably just be ~/.local/share/ltris2/ or /home/badshah/.local/share/ltris2/. The following patch may help:

---
 src/hiscores.cpp |    6 +++++-
 src/vconfig.cpp  |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

Index: ltris2-2.0/src/hiscores.cpp
===================================================================
--- ltris2-2.0.orig/src/hiscores.cpp
+++ ltris2-2.0/src/hiscores.cpp
@@ -106,7 +106,11 @@ Hiscores::Hiscores()
        /* if not found or no write access we can't use global
         * highscores file so fallback to home directory */
        _loginfo("No permission to access global highscores\n");
-       fname = getHomeDir() + "/" + CONFIGDIR + "/ltris2.hscr";
+       if (CONFIGDIR[0] == '~') {
+           fname = string(CONFIGDIR) + "/ltris2.hscr";
+       } else {
+           fname = getHomeDir() + "/" + CONFIGDIR + "/ltris2.hscr";
+       }
        _loginfo("Falling back to %s\n",fname.c_str());
    }
1 Attachments

Discussion

  • Atri

    Atri - 2024-07-31

    Actually, Wayland or Tumbleweed has nothing to do with it. It also crashes on GNOME/X11 and on Leap 15.6. So Mesa 24.x (which is in Tumbleweed) vs 23.x (in Leap 15.6) might not be a factor.

     
  • Michael Speck

    Michael Speck - 2024-09-03
    • status: open --> closed-fixed
    • Group: -->
     
  • Michael Speck

    Michael Speck - 2024-09-03

    Hi, thanks for the feedback! I'm back now and right after a system update I ran into the same problem. Libgame's dummy surfaces used a bad hardcoded pixel mask and weren't always created. Should be fixed now (also added some error messages). Thanks for the patches, I applied both, although I slightly changed the latter one. I can't remember properly but there was an issue with not expanding the ~, so it is always expanded now.

    There will be a release in the near future but you can already test it via the github repo which is public now: https://github.com/kulkanie/ltris2 (were create if you could double check if everything is really fixed before the release :)

     
  • Atri

    Atri - 2024-09-03

    I tested the main branch at commit 7d9f978 and everything works great now! Looks very pretty too, big thanks.

     

Log in to post a comment.