Subject: Re: bug#37892: 27.0.50; Crash when signaling a thread

From: Michał Krzywkowski <[email-masked]>
Date: Sun, 27 Oct 2019 11:16:03 +0100

>>>>> "Eli" == Eli Zaretskii <[email-masked]> writes:
    Eli> Michał, can you tell why you needed to call thread-signal while the
    Eli> thread was in sit-for?
    >>
    >> I wanted to signal some background thread which was doing some work and
    >> then Emacs crashed, because it just so happened that it was in sit-for.
    >> The thread function was doing _more_ than just sit-for.
    >>
    >> I actually don't care (and can't know) what another thread is doing, I
    >> just want to send a signal to it.

    Eli> But thread-signal is not for causing an error in a thread, it is for
    Eli> unblocking a thread that waits on a mutex or a condvar.  So why would
    Eli> you use it when the thread is not blocked?

Then I think documentation for that function should be changed to
explicitly say that the signal will *only* be delivered if the target
thread is in a "blocked call to ‘mutex-lock’, ‘condition-wait’, or
‘thread-join’".

Currently, the docstring of thread-signal just says that the function
will interrupt threads which are blocked, but does not actually say that
the signal will be delivered only in those cases.  In fact, it says that
it works like signal, so I don't think it's unreasonable to assume that
it will just interrupt a thread whatever it's doing.

--
Michał Krzywkowski
PGP: A5A7 06C4 28EF 8F64 2868 13A1 7BDE C129 F0B8 09A1