SDL/src
Sam Lantinga d226594fcc Workaround for bug 3049 - SDL_Init(SDL_INIT_VIDEO) - XDM authorization key matches an existing client!
malferit

Hello, I began a little program with SDL2 on Linux in C, and when I call SDL_Init(SDL_INIT_VIDEO) I get an error and this is printed in the console:

XDM authorization key matches an existing client!

I searched through Internet, and found that some people suggest to run 'xhost +' or to specify this in /etc/X11/xdm/xdm-config:

DisplayManager*authName:        MIT-MAGIC-COOKIE-1

I don't think an end user needs to know that...

But what bothered me is that first I started this little program in Pascal using the Freepascal compiler and it works. In freepascal you only use some thin header bindings in Pascal and then it links with the dynamic SDL library, so I don't understood why it worked with Freepascal and not in C.

I run ldd to the two generated applications:

Application in C:

	linux-gate.so.1 (0xffffe000)
	libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0xb76ac000)
	libpthread.so.0 => /lib/libpthread.so.0 (0xb766e000)
	libc.so.6 => /lib/libc.so.6 (0xb74e2000)
	libm.so.6 => /lib/libm.so.6 (0xb74a0000)
	libdl.so.2 => /lib/libdl.so.2 (0xb749a000)
	librt.so.1 => /lib/librt.so.1 (0xb7491000)
	/lib/ld-linux.so.2 (0xb77b3000)

Application compiled with Freepascal:

	linux-gate.so.1 (0xffffe000)
	libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0xb762a000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0xb74f3000)
	libc.so.6 => /lib/libc.so.6 (0xb7367000)
	libm.so.6 => /lib/libm.so.6 (0xb7325000)
	libdl.so.2 => /lib/libdl.so.2 (0xb731f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0xb7305000)
	librt.so.1 => /lib/librt.so.1 (0xb72fc000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb72dc000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0xb72d9000)
	libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb72d3000)
	/lib/ld-linux.so.2 (0xb7755000)

It seems that Freepascal is linking with libX11, libxcb, libXau and libXdmcp .

Linking my C application with libxcb solved the problem (linking with libXau and/or libXdmcp without libxcb didn't work). Linking with X11 links all the other libraries and works as well.

So I fill this bug report mainly to let you know about this. I don't know if it is a problem that can be solved on the libSDL side or not, but at least I hope it will help.

Hi, some tests:

1. Disabled XDM. Login in console and running 'startx'. The program works without having to link with X11.

2. Enabled XDM. Added 'DisplayManager*authName: MIT-MAGIC-COOKIE-1' to /etc/X11/xdm/xdm-config.The program works without having to link with X11.

3. Enabled XDM without 'DisplayManager*authName: MIT-MAGIC-COOKIE-1' in /etc/X11/xdm/xdm-config . I get the authentication error unless I link with X11.
2017-08-12 16:48:46 -07:00
..
atomic atomic: Patched to compile on Android. 2017-04-13 15:28:56 -04:00
audio Fixed bug 3702 - Clear error messages of SDL_LoadObject for optional libraries 2017-08-11 10:21:19 -07:00
core Fixed bug 3128 - Removing all the static variables from android SDLActivity and accompanying JNI calls. 2017-08-12 12:24:59 -07:00
cpuinfo Fixed compile error with gcc -std=c99 2017-03-06 21:25:06 -08:00
dynapi Added an API SDL_LoadFile_RW() to load all the data from an SDL data stream, and a convenience macro SDL_LoadFile() to load all the data from a file. 2017-08-09 11:58:38 -07:00
events Fixed bug 3188 - AZERTY keyboard support broken and inconsistent 2017-08-12 15:41:03 -07:00
file Fixed compiler warnings on Visual Studio 2013 2017-08-12 00:04:46 -07:00
filesystem Fixed bug 3639 - SDL_GetPrefPath returns a path with two consecutive slashes on Unix if org is omitted 2017-08-11 11:32:00 -07:00
haptic Fixed bug 3191 - haptic system on android? 2017-08-12 08:15:09 -07:00
joystick Fixed bug 3191 - haptic system on android? 2017-08-12 08:15:09 -07:00
libm Updated copyright for 2017 2017-01-01 18:33:28 -08:00
loadso Updated copyright for 2017 2017-01-01 18:33:28 -08:00
main haiku: Fixed compiling without OpenGL support. 2017-07-07 23:00:22 +02:00
power power: whoops, that should be "==" not "!=". 2017-07-03 16:45:12 -04:00
render Fixed bug 3243 - SDL_SetRenderDrawColor() behaves wrong with RGBA=0 2017-08-12 12:59:22 -07:00
stdlib More fixes for the SDL_scanf code 2017-08-12 00:01:24 -07:00
test Fixed bug 3646 - SDL_test_common.c: Add key bindings for testing SDL_SetWindowPosition 2017-08-11 10:42:26 -07:00
thread Fixed bug 3258 - SDL_TryLockMutex blocks for pthreads with FAKE_RECURSIVE_MUTEX 2017-08-11 21:47:31 -07:00
timer haiku: Changed header paths to be more compatible. 2017-07-29 23:00:14 +02:00
video Workaround for bug 3049 - SDL_Init(SDL_INIT_VIDEO) - XDM authorization key matches an existing client! 2017-08-12 16:48:46 -07:00
SDL.c Backing out broken change from previous commit. 2017-04-01 00:46:42 -04:00
SDL_assert.c assert: Better Emscripten support. 2017-05-19 14:51:03 -04:00
SDL_assert_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_dataqueue.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_dataqueue.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_error.c Fixed bug 3696 - SDL_ShowMessageBox displays different error from intended 2017-07-10 17:16:12 -07:00
SDL_error_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_hints.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_internal.h Some patches to make SDL compile with armcc (ARM's C compiler). 2017-03-02 13:33:04 -05:00
SDL_log.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00