We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1376 - libX11-1.4.99.1 adds _XGetRequest symbol which SDL must define too
Summary: libX11-1.4.99.1 adds _XGetRequest symbol which SDL must define too
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 1.2
Hardware: x86_64 Linux
: P1 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-17 05:58 UTC by Petr Pisar
Modified: 2012-12-03 03:53 UTC (History)
1 user (show)

See Also:


Attachments
Fix (754 bytes, patch)
2012-01-17 05:58 UTC, Petr Pisar
Details | Diff
Better fix. (1.80 KB, patch)
2012-01-18 00:04 UTC, Ryan C. Gordon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisar 2012-01-17 05:58:18 UTC
Created attachment 779 [details]
Fix

libX11-1.4.99.1 added new function_XGetRequest() <http://lists.x.org/archives/xorg-announce/2011-November/001756.html>. This function is declared as

extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);

thus it must be resolved by linker at run-time. This is not true with current SDL-1.2 code:

$ ldd -r -d /usr/lib64/libSDL.so 
        linux-vdso.so.1 =>  (0x00007fff2cf81000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fa7f1bf1000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fa7f19ed000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa7f17d0000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fa7f141d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa7f2199000)
undefined symbol: _XGetRequest  (/usr/lib64/libSDL.so)
Comment 1 Sam Lantinga 2012-01-17 06:06:50 UTC
Gah, Ryan, how did we handle optional X11 symbol resolution again?
Comment 2 Ryan C. Gordon 2012-01-17 17:43:36 UTC
(In reply to comment #1)
> Gah, Ryan, how did we handle optional X11 symbol resolution again?

Doh, let me look into this.

--ryan.
Comment 3 Ryan C. Gordon 2012-01-18 00:04:38 UTC
Created attachment 780 [details]
Better fix.

Attachment #779 [details] forgot the "return" keyword on the macro, and would fail if used on an older Xlib that lacks this symbol because it's listed as part of base X11.

This patch should load the symbol, and deal with old systems without the symbol when building SDL with the newer headers.

It was really irresponsible of the Xlib developers to break binary compatibility like this.

--ryan.
Comment 4 Petr Pisar 2012-01-18 05:25:50 UTC
Let me ask:

(1) Does the return keyword mean SDL returns immediately instead of calling the function from libX11? If do, then why _XFlushGCCache is missing the keyword:

SDL_X11_SYM(void,_XFlushGCCache,(Display* a,GC b),(a,b),)

I did not find the `_XFlushGCCache' anywhere else in the SDL code, thus I think it's not used by SDL.


(2) Also you check for SDL_X11_HAVE_XGETREQUEST, but

#define SDL_X11_MODULE(modname) extern int SDL_X11_HAVE_##modname;
SDL_X11_SYM(void *,_XGetRequest,(Display* a,CARD8 b,size_t c),(a,b,c),return)

should create SDL_X11_HAVE__XGetRequest symbol (double underscore). Should you check for SDL_X11_HAVE__XGETREQUEST?
Comment 5 Ryan C. Gordon 2012-01-18 07:59:40 UTC
(In reply to comment #4)
> (1) Does the return keyword mean SDL returns immediately instead of calling the
> function from libX11? If do, then why _XFlushGCCache is missing the keyword:
> 
> SDL_X11_SYM(void,_XFlushGCCache,(Display* a,GC b),(a,b),)

The "return" is needed if the function doesn't return "void" ... it's a requirement of this macro trick.

> I did not find the `_XFlushGCCache' anywhere else in the SDL code, thus I think
> it's not used by SDL.

It's used by the FlushGC macro, which the Xv support code uses.

> (2) Also you check for SDL_X11_HAVE_XGETREQUEST, but
> 
> #define SDL_X11_MODULE(modname) extern int SDL_X11_HAVE_##modname;
> SDL_X11_SYM(void *,_XGetRequest,(Display* a,CARD8 b,size_t c),(a,b,c),return)
> 
> should create SDL_X11_HAVE__XGetRequest symbol (double underscore). Should you
> check for SDL_X11_HAVE__XGETREQUEST?

No, it looks for whatever we specified for "modname" in SDL_X11_MODULE, which was "XGETREQUEST".

--ryan.
Comment 6 Sam Lantinga 2012-01-18 08:47:18 UTC
Petr, can you try out the attached patch and see if it works for you?

Thanks!
Comment 7 Petr Pisar 2012-01-19 02:56:20 UTC
Current SDL-1.2 head compiles with the old libX11 as well as with the new libX11.

After applying the patch to SDL-1.2.14, it compiles and works with old libX11. It compiles and works with new libX11.
Comment 8 Sam Lantinga 2012-01-19 07:57:31 UTC
Great, thanks!
Comment 9 student 2012-12-02 06:07:21 UTC
Hi,

Can anyone tell me and help me how to patch SDL librarz?

regards
Comment 10 Petr Pisar 2012-12-03 03:53:49 UTC
(In reply to comment #9)
> Can anyone tell me and help me how to patch SDL librarz?
> 
If you have SDL-1.2.15, you do need to apply this patch because it's already included.

If you have SDL-1.2.14, you need to adjust the patch before applying as it has been created against development SDL tree. Or you can get rebased patch from some distribution archives like this one from Fedora <http://pkgs.fedoraproject.org/cgit/SDL.git/plain/SDL-1.2.14-Define__XGetRequest.patch?id=600a62015f44deed7a5e1340a7097157cbf210fe>.