allegro5 icon indicating copy to clipboard operation
allegro5 copied to clipboard

segfault on exit on Linux

Open SiegeLord opened this issue 10 months ago • 8 comments

This happens reliably with most examples. Exact reasons unknown.

SiegeLord avatar Mar 27 '24 06:03 SiegeLord

  #include <stdio.h>
  #include <allegro5/allegro5.h>
  #include <allegro5/allegro_font.h>
  
  int main()
  {
      if(!al_init()){
          printf("couldn't initialize allegro\n");
          return 1;
      }
  
      ALLEGRO_DISPLAY* disp = al_create_display(640, 480);
      if(!disp){
          printf("couldn't initialize display\n");
          return 1;
      }    
      al_destroy_display(disp);
      printf("Return\n");
  
      return 0;
  }

Command: gcc test.c -o test $(pkg-config allegro-5 allegro_font-5 allegro_image-5 allegro_primitives-5 --libs --cflags) This prints "Return" then there is a Segmentation fault.

kris659 avatar Mar 27 '24 12:03 kris659

What Linux-distro are you on? I cannot reproduce this on Debian stable, Nvidia graphics driver, nor Debian unstable, on virtualbox on the same machine, allegro from latest git in both cases. (Neither with the allegro examples, or @kris659 short code example from here).

gusnan avatar Mar 27 '24 15:03 gusnan

I'm using Ubuntu on WSL (someone from discord is using wayland Ubuntu)

kris659 avatar Mar 27 '24 19:03 kris659

Ubuntu 22.04.3 LTS + AMD here + X11 here.

SiegeLord avatar Mar 27 '24 22:03 SiegeLord

Yeah, I am on X11 too on both my tests, just mention it for completion (Problem seems to be both X11 and wayland though).

gusnan avatar Mar 28 '24 18:03 gusnan

Spent a little time on this today. It's possible to bisect a crash like this to commit d0e57462e7db9d856056d43f24131129d1268860, but reverting it in today's Allegro does nothing (because it crashes before it gets to it for me).

One reliable way to avoid this crash for me is to call al_destroy_display or al_uninstall_system manually. Perhaps something in GLX isn't happy to work after main exits.

SiegeLord avatar Mar 29 '24 03:03 SiegeLord

So, perhaps all we have to do is add those manual calls to the examples?

ReiquelApplegate avatar Apr 22 '24 13:04 ReiquelApplegate