Fwd: XInitThreads in library constructor breaks Motif!

Adam Jackson ajax at redhat.com
Mon Oct 31 16:31:21 UTC 2022


Bah, meant to reply all here.

- ajax

---------- Forwarded message ---------
From: Adam Jackson <ajax at redhat.com>
Date: Mon, Oct 31, 2022 at 12:29 PM
Subject: Re: XInitThreads in library constructor breaks Motif!
To: Po Lu <Luangruo at yahoo.com>

On Sun, Oct 30, 2022 at 8:10 PM Po Lu <Luangruo at yahoo.com> wrote:

>
> Or most people are on Xlib 1.7.x.  Anyway, the documentation for X*IfEvent
> says it is okay to call functions that take the display lock inside the
> predicate given that it does not change the event queue.  I have written
> such software, and clearly the Open Group has too, along with XFCE, etc.
>

The documentation absolutely does not say that. The manual page says "Your
predicate procedure must decide if the event is useful without calling any
Xlib functions". Taking the display lock is an xlib function. It also
clearly _calls out_ a case where behavior will _definitely_ be undefined,
but the "do not re-enter xlib" restriction is not limited to "do not use
xlib to touch the event queue".

Besides, how to move it forward? If it works, wouldn't the obvious solution
> be to install the change? If all that is needed is for someone to try it
> out, I'd be happy to do it, but I'm pretty sure the better solution is just
> to remove the call to XInitThreads in the first place.
>

No. xlib needs to be thread safe in order for other libraries and apps to
use xcb reliably. The socket handoff mechanism between xcb and xlib _cannot
work safely_ unless the xlib display is thread safe. It will only be
thread-safe if XInitThreads was called before XOpenDisplay. The xcb-using
component cannot possibly enforce that because the xcb connection is
created by xlib, so (for example) libGL would be left with no other option
than to refuse to work on non-thread-safe displays.

- ajax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg-devel/attachments/20221031/85f49774/attachment.htm>


More information about the xorg-devel mailing list