bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25247: 26.0.50; Concurrency crashes with XLib


From: Elias Mårtenson
Subject: bug#25247: 26.0.50; Concurrency crashes with XLib
Date: Fri, 30 Dec 2016 19:21:08 +0800

On 30 December 2016 at 19:05, Eli Zaretskii <address@hidden> wrote:

> I open IELM in one window, and an empty buffer "z" in another, and type the
> following:
>
> (loop
>   repeat 10
>   do (make-thread (lambda ()
>                     (let ((n (random 10)))
>                       (with-current-buffer "z"
>                         (sleep-for n)
>                         (insert (format "Foo:%d\n" n)))))))
>
> Here, I'd expect to see the "z" buffer being updated at the corresponding
> times. I.e. the message "Foo:4" should be displayed after 4 seconds. This
> is not what I see. Instead the messages appear in batches (i.e. several
> rows appearing at the same time).

And what do the messages that appear together say in the %d part?  Do
they all show the same value?

No. They show wildly different values. For example, during one test, after roughly 8 seconds, I got 7 or so messages with number ranging from 2 to 8.

One interesting fact is that if I replace ‘sleep-for’ with ‘sit-for’, then the updates come at exactly the expected time. In other words, the unpredictable behaviour where keypresses would randomly make the ‘sit-for’ expire doesn't happen anymore.

> The following seems to be a problem with lexically bound lambda functions
> used in a thread. The following example illustrates the problem:
>
> (let ((x "test"))
>   (make-thread (lambda ()
>                  (with-current-buffer "z"
>                    (insert x)))))
>
> I would expect this to insert "test" into the buffer, but instead nothing
> happens. Removing the reference to the variable "x" in the lambda makes it
> work.

Isn't the above expected?  If not, why not?

Never mind. This one was caused by me. Please ignore it.

The problem was that ‘lexical-binding’ was set to nil in my IELM buffer.

Regards,
Elias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]