[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible issue with mutexes
From: |
Herwig Hochleitner |
Subject: |
Re: Possible issue with mutexes |
Date: |
Wed, 10 Apr 2019 18:15:24 +0200 |
On 4/10/19 5:11 PM, Eli Zaretskii wrote:
[Why private email?]
I hit the wrong reply button, sorry.
From: Herwig Hochleitner <address@hidden>
Date: Wed, 10 Apr 2019 17:02:35 +0200
Waiting on a condition var or joining a thread on the main thread can
freeze emacs totally dead. Like kill -9 dead.
Is this a known issue or should I investigate further?
Not sure if I understand correctly the situation you describe. Would
it be possible to post a simple reproducer?
Try evaluating this snippet (maybe not in your main emacs) and try
quitting out of the eval:
(let* ((m (make-mutex))
(c (make-condition-variable m)))
(with-mutex m
(condition-wait c)))
How is the above "joining a thread"?
Joining a thread shows similar behavior, where you can't quit via C-g
anymore.
(thread-join
(make-thread
(lambda ()
(let* ((m (make-mutex))
(c (make-condition-variable m)))
(with-mutex m
(condition-wait c))))))
Anyway, I think what you did is wrote code that deliberately
deadlocks, so why are you surprised it does?
That's because this is a minimal example. I'm not surprised by it
anymore ;-)
I hit this, when working on somewhat more involved code
https://github.com/NixOS/nixpkgs/blob/f4d71836af5dd99b5af32ace6d1775b91213858e/pkgs/applications/editors/emacs-modes/update-melpa.el
Theres no other thread
to signal the condition variable or signal the waiting thread.
IOW, this is the expected behavior.
Yes, pardon, I'm so used to event-driven programming, I forgot that in
Unix, everything is pull
What I'm trying to say: It would be nice, if C-g could also release
pending condition-waits and thread-joins.
I understand, that this might be kind of a hard thing to ask, due to the
lack of a separate input thread, as you say, but I'm not familiar with
the internals, so I'm asking it.
kind regards