Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-03 Thread Alan Coopersmith

On 11/3/22 04:46, Po Lu wrote:

Matthieu Herrb  writes:


My french input method has eaten the URL. here the unmangled one:

https://marc.info/?l=openbsd-tech=166742060513284=2


My crystal ball says it's probably that before XInitThreads was called,
pthread stubs somehow found their way into the executable image.

If you link the crashing program with -lpthread, does the crash
magically go away?


If that's the case, then this should already be solved in git for 1.8.2:

https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/1f8fd7ff1cf688e
https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/701e9e9afb88bdc

--
-Alan Coopersmith- alan.coopersm...@oracle.com
 Oracle Solaris Engineering - https://blogs.oracle.com/solaris


Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-03 Thread Po Lu
Matthieu Herrb  writes:

> My french input method has eaten the URL. here the unmangled one: 
>
> https://marc.info/?l=openbsd-tech=166742060513284=2

My crystal ball says it's probably that before XInitThreads was called,
pthread stubs somehow found their way into the executable image.

If you link the crashing program with -lpthread, does the crash
magically go away?


Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-03 Thread Matthieu Herrb
On Wed, Nov 02, 2022 at 10:13:02PM +0100, Matthieu Herrb wrote:
> On Wed, Nov 02, 2022 at 11:29:19AM -0700, Alan Coopersmith wrote:
> > On 11/2/22 07:53, Adam Jackson wrote:
> > > I missed that! My apologies. I've merged the reentrancy patch, we should
> > > probably push out another release shortly.
> > 
> > Now that this change is in, I'll wait a few days for any more testing to
> > be reported and then probably cut a 1.8.2 release next week.
> > 
> 
> https://marc.infœ?l=openbsd-tech=166742060513284=2

My french input method has eaten the URL. here the unmangled one: 

https://marc.info/?l=openbsd-tech=166742060513284=2

> doesn't look too good. unfortunatly no time to try to see if I can
> reproduce this before next week.
> 
> -- 
> Matthieu Herrb

-- 
Matthieu Herrb


Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-02 Thread Matthieu Herrb
On Wed, Nov 02, 2022 at 11:29:19AM -0700, Alan Coopersmith wrote:
> On 11/2/22 07:53, Adam Jackson wrote:
> > I missed that! My apologies. I've merged the reentrancy patch, we should
> > probably push out another release shortly.
> 
> Now that this change is in, I'll wait a few days for any more testing to
> be reported and then probably cut a 1.8.2 release next week.
> 

https://marc.infœ?l=openbsd-tech=166742060513284=2
doesn't look too good. unfortunatly no time to try to see if I can
reproduce this before next week.

-- 
Matthieu Herrb


Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-02 Thread Alan Coopersmith

On 11/2/22 07:53, Adam Jackson wrote:
I missed that! My apologies. I've merged the reentrancy patch, we should 
probably push out another release shortly.


Now that this change is in, I'll wait a few days for any more testing to
be reported and then probably cut a 1.8.2 release next week.

--
-Alan Coopersmith- alan.coopersm...@oracle.com
 Oracle Solaris Engineering - https://blogs.oracle.com/solaris


Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-02 Thread Adam Jackson
I missed that! My apologies. I've merged the reentrancy patch, we should
probably push out another release shortly.

- ajax

On Tue, Nov 1, 2022 at 8:16 PM Po Lu  wrote:

>
>
> On November 2, 2022 1:25:06 AM GMT+08:00, Adam Jackson 
> wrote:
> >On Mon, Oct 31, 2022 at 8:46 PM Po Lu  wrote:
>
> >Again, I proposed a workaround that preserves the thread-safety guarantee
> I
> >need, and wrote the patch implementing it. Sure would be nice if someone
> >tested it.
>
> I did say it works for the programs that broke for me.
>
>


Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-01 Thread Po Lu



On November 2, 2022 1:25:06 AM GMT+08:00, Adam Jackson  wrote:
>On Mon, Oct 31, 2022 at 8:46 PM Po Lu  wrote:

>Again, I proposed a workaround that preserves the thread-safety guarantee I
>need, and wrote the patch implementing it. Sure would be nice if someone
>tested it.

I did say it works for the programs that broke for me.


Re: Fwd: XInitThreads in library constructor breaks Motif!

2022-11-01 Thread Matthieu Herrb
On Tue, Nov 01, 2022 at 01:25:06PM -0400, Adam Jackson wrote:
> On Mon, Oct 31, 2022 at 8:46 PM Po Lu  wrote:
> 
> > Adam Jackson  writes:
> >
> > > Because XInitThreads only works if it is called before XOpenDisplay.
> >
> > So why not fix that?
> >
> > I think the simple fix would be to call _XInitDisplayLock in
> > XGetXCBConnection.
> >
> 
> That wouldn't be sufficient, off the top of my head there's library-global
> state that gets set up in XInitThreads too and none of the display-level
> locking will work without it.
> 
> Again, I proposed a workaround that preserves the thread-safety guarantee I
> need, and wrote the patch implementing it. Sure would be nice if someone
> tested it.
> 

Hi,

I'm trying to get it tested on OpenBSD where some people complained
after the import of libX11 1.8.1:

https://marc.infœ?l=openbsd-tech=166729483920618=2

On my small test case it seems to fix the issue.
-- 
Matthieu Herrb


Fwd: XInitThreads in library constructor breaks Motif!

2022-11-01 Thread Adam Jackson
On Mon, Oct 31, 2022 at 8:46 PM Po Lu  wrote:

> Adam Jackson  writes:
>
> > Because XInitThreads only works if it is called before XOpenDisplay.
>
> So why not fix that?
>
> I think the simple fix would be to call _XInitDisplayLock in
> XGetXCBConnection.
>

That wouldn't be sufficient, off the top of my head there's library-global
state that gets set up in XInitThreads too and none of the display-level
locking will work without it.

Again, I proposed a workaround that preserves the thread-safety guarantee I
need, and wrote the patch implementing it. Sure would be nice if someone
tested it.

- ajax


Fwd: XInitThreads in library constructor breaks Motif!

2022-10-31 Thread Adam Jackson
Bah, meant to reply all here.

- ajax

-- Forwarded message -
From: Adam Jackson 
Date: Mon, Oct 31, 2022 at 12:29 PM
Subject: Re: XInitThreads in library constructor breaks Motif!
To: Po Lu 

On Sun, Oct 30, 2022 at 8:10 PM Po Lu  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