all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Herwig Hochleitner <herwig@bendlas.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Possible issue with mutexes
Date: Wed, 10 Apr 2019 18:15:24 +0200	[thread overview]
Message-ID: <a1c6a91d-fb1e-6d7e-1206-cf8efc61cdd4@bendlas.net> (raw)
In-Reply-To: <83y34h6gkb.fsf@gnu.org>

On 4/10/19 5:11 PM, Eli Zaretskii wrote:

> [Why private email?]
I hit the wrong reply button, sorry.
>> From: Herwig Hochleitner <herwig@bendlas.net>
>> 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




      parent reply	other threads:[~2019-04-10 16:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-10  2:57 Possible issue with mutexes Herwig Hochleitner
2019-04-10  3:11 ` Herwig Hochleitner
2019-04-10 14:27   ` Eli Zaretskii
     [not found]     ` <79bd1b97-13e8-a761-04f8-417204a7df29@bendlas.net>
     [not found]       ` <83y34h6gkb.fsf@gnu.org>
2019-04-10 16:15         ` Herwig Hochleitner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1c6a91d-fb1e-6d7e-1206-cf8efc61cdd4@bendlas.net \
    --to=herwig@bendlas.net \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.