From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Herwig Hochleitner Newsgroups: gmane.emacs.devel Subject: Re: Possible issue with mutexes Date: Wed, 10 Apr 2019 18:15:24 +0200 Message-ID: References: <60468e7f-57a8-a263-a004-884b51461db7@bendlas.net> <834l766il3.fsf@gnu.org> <79bd1b97-13e8-a761-04f8-417204a7df29@bendlas.net> <83y34h6gkb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="19186"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 10 18:16:30 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hEFtl-0004qr-33 for ged-emacs-devel@m.gmane.org; Wed, 10 Apr 2019 18:16:29 +0200 Original-Received: from localhost ([127.0.0.1]:34198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEFtj-00083V-Vb for ged-emacs-devel@m.gmane.org; Wed, 10 Apr 2019 12:16:27 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEFt0-000832-VT for emacs-devel@gnu.org; Wed, 10 Apr 2019 12:15:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEFsy-0003y3-Uh for emacs-devel@gnu.org; Wed, 10 Apr 2019 12:15:42 -0400 Original-Received: from artox.bendlas.net ([95.183.52.41]:45156 helo=mail.bendlas.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hEFsm-0003jz-UT; Wed, 10 Apr 2019 12:15:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bendlas.net; s=mail; t=1554913133; bh=+/poAJThLnb2T/SfmEaZzvxdZwE2aR4ciFgKTtp+7Mo=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=A6BacP3C68xkGzRw1UWXVVAxgv+rz5oRPqlMXQY1q3zsGSegztSGkiaFsO8BcRNcm Jth+iBh+n9Z+Lv5McooCGyQIjN5Pv5A1PUJoK9wxq601XXUVPsYfSJ2pe+PdTtq9oN Ir0SpP6jOBX+w5W8MX8kj+BfxyR8EKxc3+ujaxe8= In-Reply-To: <83y34h6gkb.fsf@gnu.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 95.183.52.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235222 Archived-At: On 4/10/19 5:11 PM, Eli Zaretskii wrote: > [Why private email?] I hit the wrong reply button, sorry. >> From: Herwig Hochleitner >> Date: Wed, 10 Apr 2019 17:02:35 +0200 >> >> >>>> Waiting on a condition var or joining a thread on the main thread ca= n >>>> 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)) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (c (make-condition-variable m))= ) >> =C2=A0 (with-mutex m >> =C2=A0=C2=A0=C2=A0 (condition-wait c))) > How is the above "joining a thread"? Joining a thread shows similar behavior, where you can't quit via C-g=20 anymore. (thread-join =C2=A0(make-thread =C2=A0 (lambda () =C2=A0=C2=A0=C2=A0 (let* ((m (make-mutex)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (c (make-co= ndition-variable m))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (with-mutex m =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (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=20 anymore ;-) I hit this, when working on somewhat more involved code=20 https://github.com/NixOS/nixpkgs/blob/f4d71836af5dd99b5af32ace6d1775b9121= 3858e/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=20 Unix, everything is pull What I'm trying to say: It would be nice, if C-g could also release=20 pending condition-waits and thread-joins. I understand, that this might be kind of a hard thing to ask, due to the=20 lack of a separate input thread, as you say, but I'm not familiar with=20 the internals, so I'm asking it. kind regards