liballeg / allegro5

The official Allegro 5 git repository. Pull requests welcome!
https://liballeg.org
Other
1.89k stars 285 forks source link

Crash when X loses a display #814

Open pinballkeefer opened 7 years ago

pinballkeefer commented 7 years ago

When a display goes away (for example, gets unplugged), allegro crashes via the following route:

from _al_xwin_background_thread: process_x11_event() [XEvent.type is 22] [case ConfigureNotify] _al_xglx_display_configure_event() _al_xglx_display_configure() _al_xglx_get_monitor_info()

This calls xrandr_fetch_crtc which returns NULL, and then segfaults on crtc->x

Possibly a NULL check can be put in after that call and return false? The bigger problem, I suppose, is the better handling of displays that go away?

I have a core dump I can refer back to if necessary.

EDIT: Allegro version 5.1.10, haven't been able to try on latest yet.

SiegeLord commented 7 years ago

Is this windowed/fullscreen or fullscreen windowed?

pinballkeefer commented 7 years ago

It is definitely not windowed. It is most likely fullscreen windowed, but it could possibly be fullscreen. I will double check when I'm back at work tomorrow to be sure (we try both during display creation).

pinballkeefer commented 7 years ago

OK it gets created fullscreen, and then right after that gets changed (via al_set_display_flag) to fullscreen window. I didn't write that part, but the comment is: "Success - now make sure ALLEGRO_FULLSCREEN_WINDOW is on to get rid of unity top bar". As far as I can tell stepping through, the call to al_set_display_flag is successful.

SiegeLord commented 7 years ago

I don't think we even have events for these things. One way to resolve this could be to send an event (like ALLEGRO_EVENT_MONITOR_LOST) and then mark the display as permanently lost (calling stuff on it shouldn't crash, but you should destroy it at the earliest convenience).