From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#36609: 27.0.50; Possible race-condition in threading implementation Date: Fri, 12 Jul 2019 18:06:29 +0000 Message-ID: References: <87muhks3b5.fsf@hochschule-trier.de> <83muhj2zmb.fsf@gnu.org> <83ims72xcj.fsf@gnu.org> <83a7dj2sz9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="143616"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36609@debbugs.gnu.org, politza@hochschule-trier.de To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 12 20:08:07 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hlzxm-000bH7-TQ for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Jul 2019 20:08:07 +0200 Original-Received: from localhost ([::1]:51694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlzxl-0001Iu-UD for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Jul 2019 14:08:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49143) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlzxj-0001Gw-Ht for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 14:08:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlzxi-0001tt-IB for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 14:08:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlzxi-0001tm-EV for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 14:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hlzxi-0000pH-6k for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 14:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jul 2019 18:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36609 X-GNU-PR-Package: emacs Original-Received: via spool by 36609-submit@debbugs.gnu.org id=B36609.15629548333107 (code B ref 36609); Fri, 12 Jul 2019 18:08:02 +0000 Original-Received: (at 36609) by debbugs.gnu.org; 12 Jul 2019 18:07:13 +0000 Original-Received: from localhost ([127.0.0.1]:40696 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlzwu-0000o3-O2 for submit@debbugs.gnu.org; Fri, 12 Jul 2019 14:07:13 -0400 Original-Received: from mail-oi1-f170.google.com ([209.85.167.170]:40788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlzwt-0000nq-3F for 36609@debbugs.gnu.org; Fri, 12 Jul 2019 14:07:11 -0400 Original-Received: by mail-oi1-f170.google.com with SMTP id w196so7929407oie.7 for <36609@debbugs.gnu.org>; Fri, 12 Jul 2019 11:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CyLNFAqAoxb1aTAgiX1cAXGzhY8r2d5LcZWi5qjkh+s=; b=sbF8YYlKFfZz/tg5YR+wsEytD0oZ8KiS5KMVAeEHqnjvFshQqGW3ctqBS4Ndycqvhj o0v4Z1CcT2lWHPysIDoghDXzANsnhBhnFEgah0Ar88CKBFihlgdkh02A5XJLoybpuCvV OBB9QV+c4meFRr0R52kvMMvr+6mfyN7D0QtyXEmryldVNIV40T4MzSMYMnHd71PkrSnj t1wQxWWfPnYruEmef+bfJ/dAkO1yloCydoWLOsgzPhQ8GpAPSRjBNc/muH+GMzyYHhVB ql1lQZPKQULg/MJpkY53jtpL8BN1/3oidGIpEo/gMwfAfXtqBRbdkobqrybfKZGXjM/L LxNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CyLNFAqAoxb1aTAgiX1cAXGzhY8r2d5LcZWi5qjkh+s=; b=CA7Sz5BkeOqBiSkgIvuGJEYkioOjTwDaNs/ePCPttTk+lT0N1zbVJZrPxsLFPbUgob hS8a3lot8/HEHklwBoNJDKAI5M4ffHkZ93JPM3ggMlEze3c8P4nOS0e9RDeklIgIe0h3 W4hAfjhxdA1RjWp1PgWy2aNUBxQmTLyjH6a0t9wTOdXn575IRPC+GTNLLWciFdcam7Xc R75VxdKJMUe6Yv4MfKfJRy/QjPBUszPPokOTMIF1MZsfKMMK+IrofYE8UH7FeRlH6AKa iNMmFPPZ/e7+N5kOh8nYk14V6BuzfFdKrhf5lTLIGIZ6JsAbQsCno8u89cN8RJXLk2YZ qXEg== X-Gm-Message-State: APjAAAXWTlMGq/dsQ/TvC0eb9eOGUuyM0qibYgHyGqwoCb8KJ4RhZ5rC LwjYCZSQBjgxWGaUs80EEArWcGC7FY+VO7tmTX0= X-Google-Smtp-Source: APXvYqxpXc0/p1OGiMyvamy9yslWe9+H4tlXbL7WdxGG6j9gu9dYflmXjk6oCiskysSaJ9QFlJSb/HAUlD/xZv7/bs0= X-Received: by 2002:aca:2303:: with SMTP id e3mr6035516oie.112.1562954825474; Fri, 12 Jul 2019 11:07:05 -0700 (PDT) In-Reply-To: <83a7dj2sz9.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:162794 Archived-At: On Fri, Jul 12, 2019 at 3:06 PM Eli Zaretskii wrote: > > From: Pip Cet > > Date: Fri, 12 Jul 2019 13:51:48 +0000 > > Cc: politza@hochschule-trier.de, 36609@debbugs.gnu.org > > > > > If this is not the main thread, then the error handlers should be set > > > so as to log the error in last_thread_error, and then terminate the > > > thread (via exiting the thread function, AFAIR). > > > > Indeed, that's what happens; but the thread now fails to release the > > GLib lock it had previously acquired, so other threads cannot acquire > > it again, ever. > > Then we should make sure we release it when the thread function exits, That's too late, it's legitimate for the thread to have a signal handler. We need to release the lock at precisely the time that unbind_to would release it. > or before we call Fsignal from post_acquire_global_lock. There's no > reason to use the unwind-protect machinery for that, I think. If we call Fsignal, surely the unwind-protect machinery is already set up and we can safely call it? So unbind_to would work again... I guess I've changed my mind: the unwind-protect machinery does precisely what we want, we should simply document that thread_select can exit nonlocally and that the select functions need to be written to cater to that. Two places call xg_select, and they both run long after unbind_to works. Doing this without the unwind-protect machinery is difficult: for example, a comment in post_acquire_global_lock claims unbind_for_thread_switch can exit nonlocally, though I don't think that actually happens or we would have seen the bug report. What's your proposal for doing this?