Subject: bug#25247: 26.0.50; Concurrency crashes with XLib

From: Eli Zaretskii <[email-masked]>
Date: Sat, 31 Dec 2016 20:06:21 +0200

> From: Elias Mårtenson <[email-masked]>
> Date: Sun, 1 Jan 2017 01:28:10 +0800
> Cc: Tino Calancha <[email-masked]>, [email-masked], [email-masked]
> 
>  The display on the screen will only change if Emacs enters redisplay.
>  If you see the file's contents change, but the display on the screen
>  doesn't reflect that, it means Emacs does not get a chance to perform
>  redisplay, because it doesn't become idle in any of the threads that
>  are active. Which could be the case, since every time a running
>  thread is about to become idle, there's another thread ready to run.
> 
> I'm not sure exactly what you refer to when you say "ready to run". There are of course more threads, but
> none of them should be "ready to run".

"Ready to run" means here a thread that is stuck in
acquire_global_lock.  One of those threads will succeed in acquiring
the lock when the thread which was previously running releases the
lock.

> They're all sitting in 'sleep-for' already.

Those which are still waiting for their sleep period to expire will
not run, because they are inside the pselect call.  Only the threads
whose sleep period already expired are "ready to run", because they
call acquire_global_lock right after the pselect call returns.

>  > Interestingly enough, the minibuffer message does get updated.
> 
>  Displaying minibuffer messages uses a separate entry to redisplay, and
>  that entry only displays the echo area, unless it needs to resize the
>  mini-window.
> 
> I see. I did notice that calling 'redisplay' after the 'insert' makes everything work exactly the way I'd expect it to.
> 
> I guess doing that is perfectly acceptable and understandable once one has had the benefit of someone
> explaining it to him, like in this case. That said, it would be nice if I didn' thave to.

It's perfectly normal for Emacs not to redisplay when some Lisp is
running.  That is what happens here, except that "some Lisp" in this
case can come from another thread.