libSDL and $DISPLAY

Evgeni Golov evgeni at debian.org
Thu Jun 27 18:53:43 UTC 2013


Hi *,

[ writing this to -games as there are enough ppl with SDL experience
here I hope ]

as you might have seen, there have been a couple of the 1.2K crash bugs
reported for our packges. While looking into these, I discovered a funny
effect in libSDL and wanted to ask for some advice/suggestion.

Let's assume we have the following code:
#include <SDL/SDL.h>

void main() {
  if (SDL_Init (SDL_INIT_VIDEO) < 0) {
    fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    exit(1);
  }
}

and libsdl1.2, 1.3 and 2.0 (the later obviously needs a SDL2/SDL.h).

Running this should initialize SDL and exit immediately, right?
So it does when $DISPLAY has a valid value.
When you call it with garbage as $DISPLAY, or even nothing at all, thing
get funny:

2.0:
% env -i ./a.out
Unable to init SDL: No available video device
% env -i DISPLAY=foo ./a.out
Unable to init SDL: No available video device

1.3:
% env -i ./a.out
commandline read: a.out
SDL_DirectFB: Disabling linxu input


   ~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.2.10 |~~~~~~~~~~~~~~~~~~~~~~~~~~
        (c) 2001-2008  The world wide DirectFB Open Source Community
        (c) 2000-2004  Convergence (integrated media) GmbH
      ----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2012-05-20 12:49)
(*) Direct/Modules: suppress module 'x11input'
(*) Direct/Memcpy: Using libc memcpy()
(!) DirectFB/core/vt: Error opening `/dev/tty0'!
    --> Permission denied
(!) DirectFB/Core: Could not initialize 'system_core' core!
    --> Initialization error!
SDL_DirectFB: ../../src/video/directfb/SDL_DirectFB_video.c
(244):Initialization error!
(!) [23906:    0.000] --> Caught signal 11 (at 0x528, invalid address) <--
[1]    23906 abort (core dumped)  env -i ./a.out
% env -i DISPLAY=foo ./a.out
commandline read: a.out
SDL_DirectFB: Disabling linxu input


   ~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.2.10 |~~~~~~~~~~~~~~~~~~~~~~~~~~
        (c) 2001-2008  The world wide DirectFB Open Source Community
        (c) 2000-2004  Convergence (integrated media) GmbH
      ----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2012-05-20 12:49)
(*) Direct/Memcpy: Using libc memcpy()
(!) X11: Error in XOpenDisplay for 'foo'
(!) DirectFB/Core: Could not initialize 'system_core' core!
    --> Initialization error!
SDL_DirectFB: ../../src/video/directfb/SDL_DirectFB_video.c
(244):Initialization error!
(!) [23885:    0.000] --> Caught signal 11 (at 0x528, invalid address) <--

1.2:
% env -i ./a.out
Unable to init SDL: Unable to open a console terminal
% env -i DISPLAY=foo ./a.out
Unable to init SDL: Unable to open a console terminal

The fun part about 1.2 is: it does a half vt switch here. I see tty1, my
mouse from Xorg and my whole input still going to Xorg. Pressing
Ctrl+Alt+F1 to actually switch to tty1 and then Alt+F7 brings Xorg back.
This does not happen in 1.3 (besides the codedump) nor in 2.0.

I wonder: is this general SDL behavior? Or some weird combo of my
GPU/drivers/Xorg/SDL?

Input welcome

Evgeni



More information about the Pkg-sdl-maintainers mailing list