From unknown Sat Sep 06 07:58:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' Resent-From: Dmitry Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Jul 2014 03:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 18116@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.140643080823719 (code B ref -1); Sun, 27 Jul 2014 03:14:02 +0000 Received: (at submit) by debbugs.gnu.org; 27 Jul 2014 03:13:28 +0000 Received: from localhost ([127.0.0.1]:39148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XBEtr-0006AU-Aa for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48485) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XBEto-0006AE-81 for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBEtd-0008US-TR for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBEtd-0008UL-Pm for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBEtY-0000Od-RX for bug-gnu-emacs@gnu.org; Sat, 26 Jul 2014 23:13:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBEtU-0008TU-2P for bug-gnu-emacs@gnu.org; Sat, 26 Jul 2014 23:13:08 -0400 Received: from mail-we0-x230.google.com ([2a00:1450:400c:c03::230]:35570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBEtT-0008TM-Qm for bug-gnu-emacs@gnu.org; Sat, 26 Jul 2014 23:13:03 -0400 Received: by mail-we0-f176.google.com with SMTP id q58so5750857wes.7 for ; Sat, 26 Jul 2014 20:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:mime-version:content-type; bh=iK9WwqdwlsXyF+bJOcJepKO8hYTXOujFLORMUloAyqc=; b=pJzqrgPj0ZZ8iXMJmxPQ7kdbVgcyiuVWM5e1367ZFKEsdpVbSNDkKF5BhKVb5Mhtvs qoJsdEc8cn7y8xNWs5SnQIH7x+JO0CIuuFazJvK3aeaNEves77gIVCUMp46hdwzQhR4J PV7jHU1xZi3fbpgECtMqfKYgyQRBO8nx4+esVVQcHqiKiCot9iRZ5UcsCLQP7qFHAMZx pKQ3UHPg5m8BzurUPVLNgZS78n3we2si9G5v32AsFWchW/ub3t5h58vW62hP2Bc30j0W WvCA5XAtTZ7vreAZKwQMRbbuRCUaFa7/Qat+ZSIhHM+EbaKqYk44/L8i3/s/o4p+waiJ KeAg== X-Received: by 10.180.19.200 with SMTP id h8mr17833192wie.32.1406430782455; Sat, 26 Jul 2014 20:13:02 -0700 (PDT) Received: from axl (93-109-244.netrun.cytanet.com.cy. [93.109.109.244]) by mx.google.com with ESMTPSA id es9sm34038091wjd.1.2014.07.26.20.13.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 26 Jul 2014 20:13:01 -0700 (PDT) From: Dmitry Date: Sun, 27 Jul 2014 06:12:57 +0300 Message-ID: <86ppgr4hqe.fsf@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Note: this could be considered a regression from Emacs 24.3 With this test case: ``` (require 'url-http) (defvar uht-counter 0) (defun uht-callback (status) (declare (special url-http-process)) (message "%s %s" uht-counter status) (delete-process url-http-process)) (defun uht-test () (setq uht-counter (1+ uht-counter)) ;; The port must not be open. (url-http (url-generic-parse-url "http://localhost:3333") #'uht-callback (list 'foo))) ``` Evaluate `(uht-test)' and see two messages in the message log with the same counter value. The second message outputs a different STATUS value, caused by modification of `url-callback-arguments' in `url-http-async-sentinel', like this: 4 (:error (error connection-failed failed with code 111 :host localhost :service 3333) . foo) 4 (:error (error connection-failed deleted :host localhost :service 3333) :error (error connection-failed failed with code 111 :host localhost :service 3333) . foo) If the callback expects STATUS to contain some specific data structure, that can cause breakage, see https://github.com/marijnh/tern/issues/350 for an example. Now, I'm not entirely sure the problem is in `url-http'. It does not manifest in Emacs 24.3, possibly because in the current pretest, when the connection fails, the `url-http-process' is still alive when `delete-process' is called in `uht-callback'. This is not the case in the current stable Emacs (wherein, as a consequence, `uht-callback' doesn't get called the second time), so this could be a regression in the processes subsystem. In GNU Emacs 24.3.92.3 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) of 2014-07-24 on axl Repository revision: 117398 stephen.berman@gmx.net-20140722213204-51v7bp0chfei6wbx Windowing system distributor `The X.Org Foundation', version 11.0.11501000 System Description: Ubuntu 14.04.1 LTS From unknown Sat Sep 06 07:58:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Aug 2014 17:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Cc: 18116@debbugs.gnu.org Received: via spool by 18116-submit@debbugs.gnu.org id=B18116.140794960011284 (code B ref 18116); Wed, 13 Aug 2014 17:07:02 +0000 Received: (at 18116) by debbugs.gnu.org; 13 Aug 2014 17:06:40 +0000 Received: from localhost ([127.0.0.1]:42111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XHc0W-0002vw-El for submit@debbugs.gnu.org; Wed, 13 Aug 2014 13:06:40 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:42391 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XHc0T-0002vl-4h for 18116@debbugs.gnu.org; Wed, 13 Aug 2014 13:06:38 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1XHc0R-00005t-Ds; Wed, 13 Aug 2014 13:06:35 -0400 From: Glenn Morris References: <86ppgr4hqe.fsf@yandex.ru> X-Spook: cracking Crypto AG import Albanian Ortega Sundevil X-Ran: GW+:yNabS1js[p$l$|M^oAN\lqP2O):};L31:SVh|zAY0CXg>\@R?A69eaAw|y]JuLso&* X-Hue: yellow X-Attribution: GM Date: Wed, 13 Aug 2014 13:06:35 -0400 In-Reply-To: <86ppgr4hqe.fsf@yandex.ru> (Dmitry's message of "Sun, 27 Jul 2014 06:12:57 +0300") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.7 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.7 (-----) Maybe you could bisect for the cause? From unknown Sat Sep 06 07:58:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' References: <86ppgr4hqe.fsf@yandex.ru> In-Reply-To: <86ppgr4hqe.fsf@yandex.ru> Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Aug 2014 19:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 18116@debbugs.gnu.org Received: via spool by 18116-submit@debbugs.gnu.org id=B18116.140839047614942 (code B ref 18116); Mon, 18 Aug 2014 19:35:02 +0000 Received: (at 18116) by debbugs.gnu.org; 18 Aug 2014 19:34:36 +0000 Received: from localhost ([127.0.0.1]:46463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XJShP-0003sw-6U for submit@debbugs.gnu.org; Mon, 18 Aug 2014 15:34:35 -0400 Received: from smtp11.acens.net ([86.109.99.135]:19733 helo=smtp.movistar.es) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XJShL-0003se-B6 for 18116@debbugs.gnu.org; Mon, 18 Aug 2014 15:34:33 -0400 X-CTCH-RefID: str=0001.0A0B0204.53F25540.0088, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-Spam: Unknown Received: from qcore (83.41.63.18) by smtp.movistar.es (8.6.122.03) (authenticated as 981711563$telefonica.net) id 53D7869700994359 for 18116@debbugs.gnu.org; Mon, 18 Aug 2014 19:34:24 +0000 From: =?UTF-8?Q?=C3=93scar?= Fuentes Date: Mon, 18 Aug 2014 21:34:23 +0200 Message-ID: <87oavhvbgg.fsf@wanadoo.es> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Git bisect: 488ac8e4deedd56665301762fe6ad2e9e9dea7e7 is the first bad commit commit 488ac8e4deedd56665301762fe6ad2e9e9dea7e7 Author: Stefan Monnier Date: Wed May 15 14:54:49 2013 -0400 * src/process.c: Export default filters and sentinels to Elisp. (Qinternal_default_process_sentinel, Qinternal_default_process_filter): New constants. (pset_filter, pset_sentinel, make_process, Fset_process_filter) (Fset_process_sentinel, Fformat_network_address): Default to them instead of nil. (server_accept_connection): Sentinels can't be nil any more. (read_and_dispose_of_process_output): New function, extracted from read_process_output. (read_process_output): Use it; filters can't be nil. (Finternal_default_process_filter): New function, extracted from read_process_output. (exec_sentinel_unwind): Remove function. (exec_sentinel): Don't zilch sentinel while running. (status_notify): Sentinels can't be nil. (Finternal_default_process_sentinel): New function extracted from status_notify. (setup_process_coding_systems): Default filter is not nil any more. (syms_of_process): Export new Elisp functions and initialize new constants. * src/lisp.h (make_lisp_proc): New function. From unknown Sat Sep 06 07:58:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Sep 2014 02:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Cc: 18116@debbugs.gnu.org Received: via spool by 18116-submit@debbugs.gnu.org id=B18116.141031589231554 (code B ref 18116); Wed, 10 Sep 2014 02:25:02 +0000 Received: (at 18116) by debbugs.gnu.org; 10 Sep 2014 02:24:52 +0000 Received: from localhost ([127.0.0.1]:35832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XRXaV-0008Cr-2B for submit@debbugs.gnu.org; Tue, 09 Sep 2014 22:24:51 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:54367) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XRXaS-0008Ci-HH for 18116@debbugs.gnu.org; Tue, 09 Sep 2014 22:24:49 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s8A2Olj5012785; Tue, 9 Sep 2014 22:24:47 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 15DD2660D3; Tue, 9 Sep 2014 22:24:46 -0400 (EDT) From: Stefan Monnier Message-ID: References: <86ppgr4hqe.fsf@yandex.ru> Date: Tue, 09 Sep 2014 22:24:46 -0400 In-Reply-To: <86ppgr4hqe.fsf@yandex.ru> (Dmitry's message of "Sun, 27 Jul 2014 06:12:57 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5059=0 X-NAI-Spam-Version: 2.3.0.9378 : core <5059> : inlines <1273> : streams <1285918> : uri <1812227> X-Spam-Score: -3.8 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.8 (---) > (require 'url-http) > (defvar uht-counter 0) > (defun uht-callback (status) > (declare (special url-http-process)) > (message "%s %s" uht-counter status) > (delete-process url-http-process)) > (defun uht-test () > (setq uht-counter (1+ uht-counter)) > ;; The port must not be open. > (url-http (url-generic-parse-url "http://localhost:3333") #'uht-callbac= k (list 'foo))) [ Thanks a lot =D3scar for bisecting this one. ] Dmitry, could you explain a bit more of the context? The problem is that calling `delete-process' may run the sentinel (and since this is code run from the sentinel, it may end up calling the sentinel recursively). So if you don't want the sentinel to be called recursively, you'll want to (set-process-sentinel url-http-process nil) before calling delete-process (or refrain from calling delete-process). > If the callback expects STATUS to contain some specific data structure, > that can cause breakage, see https://github.com/marijnh/tern/issues/350 > for an example. The format looks normal: the STATUS is expected to be a plist holding the "history" of the connection. It can contain various ":error FOO" and ":redirect BAR" entries. I think the problem comes from a doc error, where url-http points to url-retrieve for the doc of CBARGS, whereas it uses the format of url-retrieve-internal instead. Stefan From unknown Sat Sep 06 07:58:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Sep 2014 01:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 18116@debbugs.gnu.org Received: via spool by 18116-submit@debbugs.gnu.org id=B18116.14104003623883 (code B ref 18116); Thu, 11 Sep 2014 01:53:01 +0000 Received: (at 18116) by debbugs.gnu.org; 11 Sep 2014 01:52:42 +0000 Received: from localhost ([127.0.0.1]:37161 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XRtYv-00010W-45 for submit@debbugs.gnu.org; Wed, 10 Sep 2014 21:52:41 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:38230) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XRtYs-00010N-Iq for 18116@debbugs.gnu.org; Wed, 10 Sep 2014 21:52:39 -0400 Received: by mail-la0-f54.google.com with SMTP id ge10so1397565lab.41 for <18116@debbugs.gnu.org>; Wed, 10 Sep 2014 18:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=rMBxAXK8AKYaLyvr+xBz8QayG6suhxQFVzBxSWmKjyQ=; b=BGI1iWPQTp5A9oFddqPOV6Fk6N6LghayBuuucw69NdY0AFt5OU5jR81PCxf7AcT89s l6wSwLyNeVmVVX12yDZDMA2iYnW7BzCiHSwntd5Aye4bU+lE+0h/oSf58HvyRtzyVyYJ QopG3d0Oh5Sfj49nn0PD5re0Ijhp632BdX4TYhIogIjHSwAdsXL0K7ymp5KvooTxFAy5 oU1z6Q20bLODIUcZgpxpUNQrhklHygSOkpCmIK0cy18bkjJqmiqSJM/6ya0hoctGftQA 1w187SM48n1q2w4044KbgbQWjMGlgQpTm7wauaapSM0KwiR4XTzo95j1PTpAdm3w/9WT KLuA== X-Received: by 10.112.158.170 with SMTP id wv10mr2282555lbb.66.1410400356926; Wed, 10 Sep 2014 18:52:36 -0700 (PDT) Received: from [192.168.1.3] ([178.252.98.87]) by mx.google.com with ESMTPSA id xc7sm6200765lbb.21.2014.09.10.18.52.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Sep 2014 18:52:35 -0700 (PDT) Message-ID: <54110061.1060908@yandex.ru> Date: Thu, 11 Sep 2014 05:52:33 +0400 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 References: <86ppgr4hqe.fsf@yandex.ru> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 09/10/2014 06:24 AM, Stefan Monnier wrote: > The problem is that calling `delete-process' may run the sentinel (and > since this is code run from the sentinel, it may end up calling the > sentinel recursively). I can observe a definite change in behavior, which I cannot reason about (when connection fails, the external process dies in Emacs 24.3, but still lives for some time in 24.4). Someone else should judge whether this is a bug or an intended change. > So if you don't want the sentinel to be called recursively, you'll want > to (set-process-sentinel url-http-process nil) before calling > delete-process Yes, that's more or less what we did in Tern: https://github.com/marijnh/tern/commit/21245d5b901e6dc9cfb7c8ea55220a11104a5efc >> If the callback expects STATUS to contain some specific data structure, >> that can cause breakage, see https://github.com/marijnh/tern/issues/350 >> for an example. > > The format looks normal: the STATUS is expected to be a plist holding > the "history" of the connection. It can contain various ":error FOO" > and ":redirect BAR" entries. Indeed. Looks like my misunderstanding stemmed from Tern not handling this value exactly right: it expected STATUS to have a certain length in case of an error, and when called recursively, the callback received STATUS of different length, prepended with new history. I guess there's no bug there, then. Sorry. > I think the problem comes from a doc error, where url-http points to > url-retrieve for the doc of CBARGS, whereas it uses the format of > url-retrieve-internal instead. Guess so. And both `url-http' and `url-retrieve-internal' are pretty confusing when it comes to describing the arguments that will be passed to CALLBACK. To me, "When retrieval is completed, execute the function CALLBACK, using the arguments listed in CBARGS." means that it will be called exactly with the value of CBARGS passed to `url-http', whereas instead the list gets prepended with stuff before it's passed to CALLBACK. From unknown Sat Sep 06 07:58:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Sep 2014 17:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 18116@debbugs.gnu.org Received: via spool by 18116-submit@debbugs.gnu.org id=B18116.141054255624284 (code B ref 18116); Fri, 12 Sep 2014 17:23:01 +0000 Received: (at 18116) by debbugs.gnu.org; 12 Sep 2014 17:22:36 +0000 Received: from localhost ([127.0.0.1]:39624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSUYO-0006Jb-7t for submit@debbugs.gnu.org; Fri, 12 Sep 2014 13:22:36 -0400 Received: from mercure.iro.umontreal.ca ([132.204.24.67]:53360) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSUYM-0006JU-Lb for 18116@debbugs.gnu.org; Fri, 12 Sep 2014 13:22:35 -0400 Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 8746585083; Fri, 12 Sep 2014 13:22:34 -0400 (EDT) Received: from lechon.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 8E6381E5B8A; Fri, 12 Sep 2014 13:22:11 -0400 (EDT) Received: by lechon.iro.umontreal.ca (Postfix, from userid 20848) id 6BBB1B41B5; Fri, 12 Sep 2014 13:22:11 -0400 (EDT) From: Stefan Monnier Message-ID: References: <86ppgr4hqe.fsf@yandex.ru> <54110061.1060908@yandex.ru> Date: Fri, 12 Sep 2014 13:22:11 -0400 In-Reply-To: <54110061.1060908@yandex.ru> (Dmitry Gutov's message of "Thu, 11 Sep 2014 05:52:33 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.71, requis 5, autolearn=not spam, ALL_TRUSTED -2.82, MC_TRANSFR 0.11, MC_TSTLAST 0.00) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-Spam-Status: No X-Spam-Score: -4.5 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.5 (----) >> The problem is that calling `delete-process' may run the sentinel (and >> since this is code run from the sentinel, it may end up calling the >> sentinel recursively). > I can observe a definite change in behavior, which I cannot reason about I think there is indeed a change of behavior in that the sentinel used to be nil'd while running it. [ This was changed because it prevented the sentinel from modifying itself. ] > Indeed. Looks like my misunderstanding stemmed from Tern not handling this > value exactly right: it expected STATUS to have a certain length in case of > an error, and when called recursively, the callback received STATUS of > different length, prepended with new history. Right, it should use (cons nil ) instead of (list ), since the `car' is used to carry the "historical events" of the request. > I guess there's no bug there, then. Sorry. Maybe not code-wise, but docstring-wise I think there's at least "room for improvement". > Guess so. And both `url-http' and `url-retrieve-internal' are pretty > confusing when it comes to describing the arguments that will be passed > to CALLBACK. > To me, "When retrieval is completed, execute the function CALLBACK, using > the arguments listed in CBARGS." means that it will be called exactly with > the value of CBARGS passed to `url-http', whereas instead the list gets > prepended with stuff before it's passed to CALLBACK. Can you improve those docstrings, to avoid such confusion in the future? Stefan From unknown Sat Sep 06 07:58:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Dmitry Subject: bug#18116: closed (Re: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process') Message-ID: References: <541B8E27.1060603@yandex.ru> <86ppgr4hqe.fsf@yandex.ru> X-Gnu-PR-Message: they-closed 18116 X-Gnu-PR-Package: emacs Reply-To: 18116@debbugs.gnu.org Date: Fri, 19 Sep 2014 02:01:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1411092063-9299-1" This is a multi-part message in MIME format... ------------=_1411092063-9299-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS = if the former calls `delete-process' which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 18116@debbugs.gnu.org. --=20 18116: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D18116 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1411092063-9299-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 18116-done) by debbugs.gnu.org; 19 Sep 2014 02:00:15 +0000 Received: from localhost ([127.0.0.1]:44978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XUnUd-0002Oo-80 for submit@debbugs.gnu.org; Thu, 18 Sep 2014 22:00:15 -0400 Received: from mail-la0-f50.google.com ([209.85.215.50]:38838) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XUnUa-0002Og-TM for 18116-done@debbugs.gnu.org; Thu, 18 Sep 2014 22:00:13 -0400 Received: by mail-la0-f50.google.com with SMTP id ty20so2269829lab.37 for <18116-done@debbugs.gnu.org>; Thu, 18 Sep 2014 19:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Y/pRKEt6pb6zHgL/z5mpvMPLZOePTb/RgLYOrP3qjGI=; b=OOva+pFDX7icMH1bCfcNV8DsmDpO7UqTmy5cmw+ExO77Zdf7Xo7NUT5YkvLaLa0pwO ESaJu1PKTna6vu/Fceb2VJYy1ut85CkvB9CSwWSg4p2yY5xhLar1IWVCK6PQi3dvxvTt cawSF2hGuUNA0Ux7v7l+Tnk+BYBeMCZtyMAJI9VTiMbh9E0x55baIgoCesvHRE+s1eat idso/P9gbYKSH3tg9Xf+2FW7oKTqJ5kU8x1Es1fRQR8vxRlHVCKSJI1Om4qG+ZjKUCf/ LiMoI/7Q4LpK980+VWTsVEkUqZVH5z9GAJVXvQc0BfaWDJ+J0UdJWyh8QyQ2P6XpmMav 5rwQ== X-Received: by 10.112.88.133 with SMTP id bg5mr3021765lbb.93.1411092011595; Thu, 18 Sep 2014 19:00:11 -0700 (PDT) Received: from [192.168.1.3] ([178.252.98.87]) by mx.google.com with ESMTPSA id qr9sm131726lbb.11.2014.09.18.19.00.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Sep 2014 19:00:10 -0700 (PDT) Message-ID: <541B8E27.1060603@yandex.ru> Date: Fri, 19 Sep 2014 06:00:07 +0400 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: Stefan Monnier Subject: Re: bug#18116: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' References: <86ppgr4hqe.fsf@yandex.ru> <54110061.1060908@yandex.ru> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18116-done Cc: 18116-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Version: 24.3.93.4 On 09/12/2014 09:22 PM, Stefan Monnier wrote: > I think there is indeed a change of behavior in that the sentinel used > to be nil'd while running it. > [ This was changed because it prevented the sentinel from modifying itself. ] Okay, I guess. >> To me, "When retrieval is completed, execute the function CALLBACK, using >> the arguments listed in CBARGS." means that it will be called exactly with >> the value of CBARGS passed to `url-http', whereas instead the list gets >> prepended with stuff before it's passed to CALLBACK. > > Can you improve those docstrings, to avoid such confusion in the future? Done, I think (r117511). Although maybe we should remove the middle paragraph in `url-http' docstring and replace it with a reference to `url-retrieve-internal': its second sentence has very much the same contents, only using different words. ------------=_1411092063-9299-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Jul 2014 03:13:28 +0000 Received: from localhost ([127.0.0.1]:39148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XBEtr-0006AU-Aa for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48485) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XBEto-0006AE-81 for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBEtd-0008US-TR for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBEtd-0008UL-Pm for submit@debbugs.gnu.org; Sat, 26 Jul 2014 23:13:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBEtY-0000Od-RX for bug-gnu-emacs@gnu.org; Sat, 26 Jul 2014 23:13:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBEtU-0008TU-2P for bug-gnu-emacs@gnu.org; Sat, 26 Jul 2014 23:13:08 -0400 Received: from mail-we0-x230.google.com ([2a00:1450:400c:c03::230]:35570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBEtT-0008TM-Qm for bug-gnu-emacs@gnu.org; Sat, 26 Jul 2014 23:13:03 -0400 Received: by mail-we0-f176.google.com with SMTP id q58so5750857wes.7 for ; Sat, 26 Jul 2014 20:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:mime-version:content-type; bh=iK9WwqdwlsXyF+bJOcJepKO8hYTXOujFLORMUloAyqc=; b=pJzqrgPj0ZZ8iXMJmxPQ7kdbVgcyiuVWM5e1367ZFKEsdpVbSNDkKF5BhKVb5Mhtvs qoJsdEc8cn7y8xNWs5SnQIH7x+JO0CIuuFazJvK3aeaNEves77gIVCUMp46hdwzQhR4J PV7jHU1xZi3fbpgECtMqfKYgyQRBO8nx4+esVVQcHqiKiCot9iRZ5UcsCLQP7qFHAMZx pKQ3UHPg5m8BzurUPVLNgZS78n3we2si9G5v32AsFWchW/ub3t5h58vW62hP2Bc30j0W WvCA5XAtTZ7vreAZKwQMRbbuRCUaFa7/Qat+ZSIhHM+EbaKqYk44/L8i3/s/o4p+waiJ KeAg== X-Received: by 10.180.19.200 with SMTP id h8mr17833192wie.32.1406430782455; Sat, 26 Jul 2014 20:13:02 -0700 (PDT) Received: from axl (93-109-244.netrun.cytanet.com.cy. [93.109.109.244]) by mx.google.com with ESMTPSA id es9sm34038091wjd.1.2014.07.26.20.13.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 26 Jul 2014 20:13:01 -0700 (PDT) From: Dmitry To: bug-gnu-emacs@gnu.org Subject: 24.3.92; url-http calls CALLBACK recursively with malformed CBARGS if the former calls `delete-process' Date: Sun, 27 Jul 2014 06:12:57 +0300 Message-ID: <86ppgr4hqe.fsf@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Note: this could be considered a regression from Emacs 24.3 With this test case: ``` (require 'url-http) (defvar uht-counter 0) (defun uht-callback (status) (declare (special url-http-process)) (message "%s %s" uht-counter status) (delete-process url-http-process)) (defun uht-test () (setq uht-counter (1+ uht-counter)) ;; The port must not be open. (url-http (url-generic-parse-url "http://localhost:3333") #'uht-callback (list 'foo))) ``` Evaluate `(uht-test)' and see two messages in the message log with the same counter value. The second message outputs a different STATUS value, caused by modification of `url-callback-arguments' in `url-http-async-sentinel', like this: 4 (:error (error connection-failed failed with code 111 :host localhost :service 3333) . foo) 4 (:error (error connection-failed deleted :host localhost :service 3333) :error (error connection-failed failed with code 111 :host localhost :service 3333) . foo) If the callback expects STATUS to contain some specific data structure, that can cause breakage, see https://github.com/marijnh/tern/issues/350 for an example. Now, I'm not entirely sure the problem is in `url-http'. It does not manifest in Emacs 24.3, possibly because in the current pretest, when the connection fails, the `url-http-process' is still alive when `delete-process' is called in `uht-callback'. This is not the case in the current stable Emacs (wherein, as a consequence, `uht-callback' doesn't get called the second time), so this could be a regression in the processes subsystem. In GNU Emacs 24.3.92.3 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) of 2014-07-24 on axl Repository revision: 117398 stephen.berman@gmx.net-20140722213204-51v7bp0chfei6wbx Windowing system distributor `The X.Org Foundation', version 11.0.11501000 System Description: Ubuntu 14.04.1 LTS ------------=_1411092063-9299-1--