From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73199: url-retrieve is not thread-safe Date: Wed, 02 Oct 2024 18:34:55 +0200 Message-ID: <87wmiq8nv4.fsf@gmx.de> References: <87cyl9j6ng.fsf@gmx.de> <875xqqk5oq.fsf@gmx.de> <87wmit9nvh.fsf_-_@gmx.de> <86frph2lqd.fsf@gnu.org> <87seth9jow.fsf@gmx.de> <86cykl2g9i.fsf@gnu.org> Reply-To: Michael Albinus Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13542"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: AlexHarsanyi@gmail.com, fitzsim@fitzsim.org, monnier@iro.umontreal.ca, 73199@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 02 18:36:27 2024 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 1sw2Kw-0003Mi-V1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Oct 2024 18:36:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sw2Ke-0008S4-Pc; Wed, 02 Oct 2024 12:36:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sw2KY-0008Pr-Ty for bug-gnu-emacs@gnu.org; Wed, 02 Oct 2024 12:36:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sw2KY-00065u-Jm for bug-gnu-emacs@gnu.org; Wed, 02 Oct 2024 12:36:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=oqBqZqIRdF+EgDtYmkPnOreEu4Y8+b7n19cXSB2B3zU=; b=EWF476y0RiKgvIDhTzUiMuL0gBIsGdIx4HCJ9e70AKn4enc3sTpPtOU2FXNtI9hHUDkejw/ppwxP8RaUG3+SbHNPjwSmeiCA4hAsms0gkZFZ6Ccuf3qmoH/DrTu4LY1h0/ZyjjIgyW8xtIGEmmTvG6oBfvRXAaqrxuFy/QK4j5gfMPvl7FfcG9Oz2JBuAOhSARNZ50FHOzeUhVA2WsXtTumHkAaU6i02LPI6FVLijjVnzOxUFySoEsF22MHktPhdGS8P5rO49KDne10H4zB5/ABzuyma3yuwSMXNNIClDkTpVz5j2cbpQWdJ4u9wYJTuhWwX4dOI4UO4hLzgwaP6LQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sw2KY-0002l7-6o for bug-gnu-emacs@gnu.org; Wed, 02 Oct 2024 12:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Oct 2024 16:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73199 X-GNU-PR-Package: emacs Original-Received: via spool by 73199-submit@debbugs.gnu.org id=B73199.172788692810553 (code B ref 73199); Wed, 02 Oct 2024 16:36:02 +0000 Original-Received: (at 73199) by debbugs.gnu.org; 2 Oct 2024 16:35:28 +0000 Original-Received: from localhost ([127.0.0.1]:59092 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sw2Jz-0002k8-Q7 for submit@debbugs.gnu.org; Wed, 02 Oct 2024 12:35:28 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:33947) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sw2Jx-0002jt-20 for 73199@debbugs.gnu.org; Wed, 02 Oct 2024 12:35:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1727886906; x=1728491706; i=michael.albinus@gmx.de; bh=oqBqZqIRdF+EgDtYmkPnOreEu4Y8+b7n19cXSB2B3zU=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=jwJYhlKdWbfoWcuTfCybHyV9lFxxH83xVClxhi6HLyt/4TOiXEHpstaJTZLmmsU/ s1KxUSnaej+PI+yDuln5pYuFJbtpSg64A7gxzcp0xhqB9IEIsehndyzKUn2geeXMn BHr+VI2HWTqyYvh5FsjEq0LVKjPSbmxWIAOwxM8lPYQg3mOg8h1CsSUvn1amBSVz4 gGPlItRpbkgX9Jj72cOK2Iuti5O5CM4G/cPK1vRl/2y9sTvyobGGlXAPk11ww0Hk9 X5kH+0tyY6hyyxjxb0XqnpeXvkntLuYOyX0vKKXoFRoco3lpu14NHQcruXpOGbU6g QNpib1zQJyAeboOaNw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MxUnz-1ryQXg2jDF-00tvwi; Wed, 02 Oct 2024 18:35:06 +0200 In-Reply-To: <86cykl2g9i.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 30 Sep 2024 20:38:49 +0300") X-Provags-ID: V03:K1:zzrahammdckDPNU32UFnP8zDDNwCmTMmadpVJrIHbq0fJ/p7v+2 piWIs8o42SNttbvQnRO7NOETsYPDowhazr60fpJ1SJC+67Fnlas94juT8Qw6XKSI2Ts90HW UwdtttAXpxk+qY83ZXfprwrWKssIsHkYMYTqoVGmCXiU3/ExPLHIMSpVoW5e/n28z/eTIkf 6FIQEjhc9A9xC3t4m4GOw== UI-OutboundReport: notjunk:1;M01:P0:axmwujf9HC0=;gdySRMZ0W1nt16gsdFuMR8bMqB+ KF3TdPLS+xIunnuhOdVVqBM637beWdwaYEv8uJdgZPfDmVolY8XFgxa0ZX0rbxWLAsYvQqwfo AKdX9blbGRvplURZ9hF+mo1RaiIbN2KTDYBOG8a9TMJ/mmif831YDgYt7VmYhU5uVYkkpC1vt IZyS5oKiV/b43/DEjYINUWSk2bb8w6NRcAfJ14dUkXQwRRmvzAp5ouy/sFmplPWflhAyMnn0n vCKZSYpbTRU26bRdgUB4cohpwBra8SgY410v6Z4Hjt2LsK4a/hfGCJw0vJeRPbsBOt8E90p4I uK5EwyPmE1bKEo4GvJkGfTuncsFc6c0VqjkvnRNFgMOguVgeqsNpeileGqoPXDgmTj2qEm4Qn vNMkU6I5PdZBenJ3SYK2CrNqaBIkTq4NXDj9ofLGYfijsbTS98zn1abVRiYZhQJ5MeGN/5Wow MTUiuMBokEC6L6djwijXlhrGNXIU49knbjSqoGSpmeM9YBeos3CdVce4/oIU/YXrHpejJvlih 8y1CgUYsrkmXDAz+ifAEJisj/AkrxlqGVx2lzsXkFtOcI4e1XnK6L6C5jez/H2USiqpnQUD5h s/LnBmqczQW2qlkM0JGd5Se4I2bqxROGWSTofIKbZc0oOGRxromGIfrjq2VjyPgMcbUEZXCaG 4CazAXsGzUztRnFMaIg0+2mKUGMJfuYz8SWg97kgO8Bfnvu8axp4PaWNK4+GK9TIS4Ech4t5+ 9/Bc0RXe4LOv7B5krymYeYKgPelr4ee7HR1IGdoZzEPzCWryjLt4Jx1GfpdqgLpHPmGrpP77 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292848 Archived-At: Eli Zaretskii writes: >> From: Michael Albinus >> Cc: 73199@debbugs.gnu.org, AlexHarsanyi@gmail.com, fitzsim@fitzsim.org, >> monnier@iro.umontreal.ca >> Date: Mon, 30 Sep 2024 18:42:55 +0200 >> >> Oops, sorry. I've appended the vc-dir buffer, not the vc-diff ... > > Thanks. I'd appreciate if you could explain why url-retrieve is > currently not thread-safe, and how this patch is supposed to solve > that. In , there's a recipe for reproduction. The general problem is when you want to access the same HTTP server from a different thread, and url-http-attempt-keepalives is set to t. This happens, for example, in debbugs 0.41. Let's assume, there is an access to debbugs:443 from a given thread, for example the main thread. Soap-client serves. It also binds url-http-attempt-keepalives to t, the https process stays alive. Later on, there is an access to debbugs:443 from another thread. It checks, whether there is a running process for that target, and tries to reuse. We get the error --8<---------------cut here---------------start------------->8--- Error #: (error "Attempt to accept output from process debbugs.gnu.org locked to thread #") --8<---------------cut here---------------end--------------->8--- My patch tries to fix this. The list of still open processes is the hash table url-http-open-connections. It has the ky (cons host port), and as value a list of processes. My patch changes this such a way, that the key is now (list host port thread). Therefore, only open processes which belong to the same thread are checked. This seems to work sufficiently. Best regards, Michael.