Closed SDLBugzilla closed 3 years ago
SDL2 handled this by calling XInitThreads() as soon as SDL_X11_LoadSymbols succeeds: https://github.com/SDL-mirror/SDL/commit/635ebd967b7a8141e1022ed5c6b462df906f5c3a
@icculus, @slouken: I'd like to apply following XInitThreads patch here: Without it, I can't run tucnak under valgring for debugging. (i.e. for https://github.com/libsdl-org/sdl12-compat/issues/182)
video/x11/SDL_x11video.c: add XInitThreads to X11_CreateDevice.
Fixes: https://bugzilla.libsdl.org/show_bug.cgi?id=2843
https://github.com/libsdl-org/SDL-1.2/issues/753
Also see SDL2 commit:
https://github.com/libsdl-org/SDL/commit/635ebd967b7a8141e1022ed5c6b462df906f5c3a
diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h
index bd83f7f..bc54b96 100644
--- a/src/video/x11/SDL_x11sym.h
+++ b/src/video/x11/SDL_x11sym.h
@@ -76,6 +76,7 @@ SDL_X11_SYM(int,XMoveResizeWindow,(Display* a,Window b,int c,int d,unsigned int
SDL_X11_SYM(int,XMoveWindow,(Display* a,Window b,int c,int d),(a,b,c,d),return)
SDL_X11_SYM(int,XNextEvent,(Display* a,XEvent* b),(a,b),return)
SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char* a),(a),return)
+SDL_X11_SYM(Status,XInitThreads,(void),(),return)
SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return)
SDL_X11_SYM(int,XPending,(Display* a),(a),return)
SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return)
diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index bbf0d5d..b4f9f1b 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -103,6 +103,7 @@ static SDL_VideoDevice *X11_CreateDevice(int devindex)
SDL_VideoDevice *device = NULL;
if ( SDL_X11_LoadSymbols() ) {
+ XInitThreads();
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
if ( device ) {
FWIW, here is the failure, which doesn't happen with the patch applied:
==5380== Memcheck, a memory error detector
==5380== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==5380== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==5380== Command: ./tucnak
==5380==
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
tucnak: xcb_io.c:259: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
==5380==
Go ahead and do it.
This bug report was migrated from our old Bugzilla tracker.
Reported in version: 1.2.15 Reported for operating system, platform: Linux, x86_64
Comments on the original bug report:
On 2015-01-12 12:02:20 +0000, Petr Pisar wrote:
On 2015-02-01 10:29:56 +0000, wrote:
On 2015-08-25 09:38:21 +0000, Ryan C. Gordon wrote: