From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#45117: 28.0.50; process-send-string mysteriously exiting non-locally when called from timer Date: Tue, 08 Dec 2020 11:44:39 +0000 Message-ID: <87h7ow4j4o.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27706"; mail-complaints-to="usenet@ciao.gmane.io" To: 45117@debbugs.gnu.org, eliz@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 08 12:45:31 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmbQx-00074y-8i for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Dec 2020 12:45:31 +0100 Original-Received: from localhost ([::1]:53116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmbQw-0006yJ-80 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Dec 2020 06:45:30 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmbQV-0006xM-2g for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2020 06:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmbQU-0000YM-RF for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2020 06:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kmbQU-0005SP-Og for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2020 06:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Dec 2020 11:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45117 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, eliz@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160742789920945 (code B ref -1); Tue, 08 Dec 2020 11:45:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Dec 2020 11:44:59 +0000 Original-Received: from localhost ([127.0.0.1]:56727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kmbQQ-0005Rl-PQ for submit@debbugs.gnu.org; Tue, 08 Dec 2020 06:44:59 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:47038) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kmbQN-0005RZ-GX for submit@debbugs.gnu.org; Tue, 08 Dec 2020 06:44:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmbQL-0006rn-JA for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2020 06:44:55 -0500 Original-Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:55298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmbQF-0000Q4-GI; Tue, 08 Dec 2020 06:44:53 -0500 Original-Received: by mail-wm1-x32a.google.com with SMTP id x22so1828220wmc.5; Tue, 08 Dec 2020 03:44:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sb9N9notJM/OQfF8tvtTXUQxyY0CTWZEsdpDbGTT0Ps=; b=hJRfhLErWqmFCn7HzMFfFPPzusjQKg/8m3scO+aJC9fYsYqBoFGbLr0kBctiFIbz58 DKy/aaYcbrm9Wh1TDtNEliWBTBEWMB13EIaO1aPLVzs5euNtVNH1RliHaIx2eHX17Y6y MNdaneGwkDGdrojZiUNdvKayCFC3vI6WzGmj3ohG9ReJA33TGIJgNDx1DbzXNh67lXp4 qHekGilBT0mwAtgeZKt9NitXdlQIONxJF9EE2cyfl/4OOaSw57Jg/MpaGVvXmB7RGWxT O7FIJkThTQpsL5QcOua9Le/8s1MaktZ/DvnHC0xzo2BVHWEm0JWx3peJvFT9NH9HzvMq qo8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sb9N9notJM/OQfF8tvtTXUQxyY0CTWZEsdpDbGTT0Ps=; b=HXzX8/XiHOhdamSnpUMvG1Odyqd24mWF48bvc1xif8tjnd7sI+4eIWS6kS07tPNCLR FLg+r7NcRfyD9o0+fRnYnlFNLsvK0Hn594/rZfelkf5Z/d16qA8deuQrT0cr+8J7pIG1 iLD59/O5IoBSpw6WzE4Co8UlOha4DEHJM0U1OQp0dOS5ZoGKWhu2gthrt6pdeqdNQLdi xm4SyJvAf6Rk06bSSieWdt+7YTKjEuo5pOkYkspKtMh8lJgs8QFku6zinWE/g3nVfTc5 kwtjNNysNP3XA4deXbde2Ct58FV6fpKFv1LlqDz0eRn1BL4EbovLIrPhrc+kFI3aUT34 TwWQ== X-Gm-Message-State: AOAM530cyZ3AIGJHSfi/sYbBphO0Jt8Tco+lSF0I6zfRgvC+99jxAJAx zhS0nU3hOtcJ3LPnlnq2M5uIs4HUYhI= X-Google-Smtp-Source: ABdhPJzzw8fyeagwNihxbx9p7lb0Id5F4gCYeIvegscE4e0dxQvCZNZNZy4f0Zv1TcD7HNgix6yLFA== X-Received: by 2002:a1c:a9c4:: with SMTP id s187mr3528529wme.116.1607427881850; Tue, 08 Dec 2020 03:44:41 -0800 (PST) Original-Received: from krug ([87.196.174.9]) by smtp.gmail.com with ESMTPSA id j7sm3088010wmb.40.2020.12.08.03.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 03:44:41 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=joaotavora@gmail.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:195323 Archived-At: Hi Maintainers, Eli When using SLY Common Lisp IDE package for Emacs, a user has recently reported a strange intermittent error in SLY's asynchronous ElDoc function. That function produces documenttion by querying a network process, a common technique in many such IDEs. The user found that when reducing eldoc-idle-delay to 0.1 he could trigger the problem more often. The original report lives at https://github.com/joaotavora/sly/issues/385. It was triggered with Emacs 27.1, but I have also reproduced it with a recent master build. After analysing the problem, I came to the conclusion that given certain mysterious conditions, process-send-string, which is called from SLY's `eldoc-documentation-function` will abruptly return non-locally even though no error or quit seems to have been signalled. For now, reproducing this means installing SLY, which is easily done with a git clone of its source at github.com/joaotavora/sly.git. One also needs a `lisp` executable pointing to something like SBCL (South Bank Common Lisp). Then emacs -Q -L . -l sly-autoloads -f sly should bring up Emacs with SLY and nothing else. To trigger the error it's easier to M-: (setq eldoc-idle-delay 0.05) C-x C-f ~/path/to/sly/slynk/slynk.lisp ;; or some other lisp file Now, the user should navigate around, triggering ElDoc and seeing the documentation in the echo area, until one gets an "unexpected reply" error in the minibufer. Interestingly, this unexpected reply comes from the fact that the network process where process-send-string is writing to has already processed the request (presumably fully), and has answered. Thus the process's filter function has been run with that output. Unfortunately, because process-send-string exited prematurely and non-locally (under line 2 in the sly.el snippet below), the so-called continuation lambda hasn't been registered (line 3). Thus when the filter function runs (code not shown) it will fail to find the continuation and report an unexpected reply. 1 (let ((id (cl-incf (sly-continuation-counter)))) 2 (sly-send `(:emacs-rex ,form ,package ,thread ,id ,@extra-options)) 3 (push (cons id continuation) (sly-rex-continuations)) 4 (sly--refresh-mode-line)) Reading process-send-string's docstring I see no mention of this possibility, only the fact that output can be accepted between bunches of strings. While the latter could happen, I'm pretty sure that the Lisp network process wouldn't have enough information to work with, prematurely, so I don't think that's the reason for the unexpected reply. Moreover, reading the C source for process.c I do see some worries with timers in code comments. However, I cannot correlate those worries with this use case. I'll be soon patching this in SLY with an unwind-protect that only adds the continuation if process-send-string has exited locally. That should hide this hard-to-trigger problem, but the underlying problem remains. Thanks for your attention, Jo=C3=A3o PS: Recently, I've also seen similar "silent" non-local-exits with accept-process-output when called from filter functions, but I will report these separately once I have better reproduction recipes.