Segfault only occurs when pressing launch/debug button from vscode

141 Views Asked by At

I am trying to use Allegro 5's native file dialog addon, but I am getting a seg fault. This issue only occurs if I press the debug or launch button from the bottom of vscode, or if I run it from the CMake/Launch terminal within vscode.

My app does not seg fault if I run it from the bash terminal.

I believe I am having any issue with the vscode-cmake-tools, but I just cannot figure out what.

I have boiled it down to the below code triggering a seg fault, the al_show_native_file_dialog() line is where it crashes.

#include <stdio.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>

int main()
{
   al_init();
   al_init_native_dialog_addon();

   ALLEGRO_DISPLAY *disp = al_create_display(800, 800);

   ALLEGRO_FILECHOOSER *fc = al_create_native_file_dialog(NULL, "Test", NULL, ALLEGRO_FILECHOOSER_FILE_MUST_EXIST);

   if (!fc || !disp) return 1;
   
   al_show_native_file_dialog(disp, fc);

   if (al_get_native_file_dialog_count(fc) > 0)
   {
      printf("%s\n", al_get_native_file_dialog_path(fc, 0));
   }

   al_destroy_native_file_dialog(fc);

   al_destroy_display(disp);

   return 0;
}

I've been told on the Allegro.cc forums that it can crash if I try to write to a protected location, but in this example it just opens a dialog showing your recent files.

I am posting here because it seems less like an Allegro issue (as it does work without issue running from the terminal), and more of a vscode problem I'm having.

Any ideas why it might crash when launching from one terminal and not the other?

EDIT: Backtrace:

#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:240
#1  0x00007ffff60b079d in  () at /lib/x86_64-linux-gnu/libpng16.so.16
#2  0x00007ffff60a0538 in  () at /lib/x86_64-linux-gnu/libpng16.so.16
#3  0x00007ffff60a09d8 in  () at /lib/x86_64-linux-gnu/libpng16.so.16
#4  0x00007ffff60a0cbb in  () at /lib/x86_64-linux-gnu/libpng16.so.16
#5  0x00007ffff60a0eab in png_process_data () at /lib/x86_64-linux-gnu/libpng16.so.16
#6  0x00007fffdc550cd9 in  () at /snap/code/93/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.so
#7  0x00007ffff6b8e281 in  () at /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0
#8  0x00007ffff6b8eb15 in gdk_pixbuf_loader_close () at /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0
#9  0x00007ffff6b8b233 in  () at /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0
#10 0x00007ffff6b8c2c1 in gdk_pixbuf_new_from_stream () at /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0
#11 0x00007ffff76f257f in  () at /lib/x86_64-linux-gnu/libgtk-3.so.0

Output of program in CMake/Launch terminal, and bash terminal: Output of program in CMake/Launch terminal, and bash terminal

0

There are 0 best solutions below