From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#49449: 28: TLS connection never gets to "open" stage Date: Thu, 8 Jul 2021 09:59:26 +0200 Message-ID: <22155A42-4A01-4EF1-80BC-B9CDE31ED0B1@acm.org> References: <87lf6h3nj0.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24257"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49449@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 08 10:00:12 2021 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 1m1Ox9-00068i-P0 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Jul 2021 10:00:11 +0200 Original-Received: from localhost ([::1]:53068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Ox8-0000Nz-QB for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Jul 2021 04:00:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1Ox1-0000Lw-6C for bug-gnu-emacs@gnu.org; Thu, 08 Jul 2021 04:00:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1Ox0-0002VE-US for bug-gnu-emacs@gnu.org; Thu, 08 Jul 2021 04:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m1Ox0-0004jv-RU for bug-gnu-emacs@gnu.org; Thu, 08 Jul 2021 04:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Jul 2021 08:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49449 X-GNU-PR-Package: emacs Original-Received: via spool by 49449-submit@debbugs.gnu.org id=B49449.162573118118160 (code B ref 49449); Thu, 08 Jul 2021 08:00:02 +0000 Original-Received: (at 49449) by debbugs.gnu.org; 8 Jul 2021 07:59:41 +0000 Original-Received: from localhost ([127.0.0.1]:54203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1Owf-0004iq-Cn for submit@debbugs.gnu.org; Thu, 08 Jul 2021 03:59:41 -0400 Original-Received: from mail1460c50.megamailservers.eu ([91.136.14.60]:48570 helo=mail267c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1Owa-0004iY-AB for 49449@debbugs.gnu.org; Thu, 08 Jul 2021 03:59:40 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1625731169; bh=lgCqrLrFMvOONMF82AO5DVhNVjtyHjfLBL8d1XpzybE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=PcNIcVS28D3iViwzGefA1I2DRr+XWGTWuKOpW07PAtOT3lOClBqhXKAEyce4JLeOj lDNTaC/0Q/jpgNhLVoeJiynxn/8SV7AfLwEE54cxvnTJNKPl/aMwYE+1OqYbgqzb// vfUI9hpdZjYOBqZIdEyggKX4y3qBOwlFXQpnp//0= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail267c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 1687xQPT024522; Thu, 8 Jul 2021 07:59:28 +0000 In-Reply-To: <87lf6h3nj0.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.21) X-CTCH-RefID: str=0001.0A742F1B.60E6B061.000A, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=S9SnP7kP c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=XkBEf6APia05Qm7OjcEA:9 a=CjuIK1q_8ugA:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE 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:209661 Archived-At: 7 juli 2021 kl. 21.57 skrev Lars Ingebrigtsen : > Yes, it's grown somewhat organically. :-/ Let me first say that the state of the code is not your fault! It's a = product, as you say, from organic growth, and it does need a rewrite. > I'm not able to reproduce this on Debian/bullseye, but on Macos I get >=20 > callback: status =3D (:error (error connection-failed "connect" :host = "elpa.gnu.o\ > rg" :service 443)) Yes, that is my observation too. Obviously the busy-wait part is = essential: removing it makes the problem go away. Essentially, the busy-wait postpones the call to = wait_reading_process_output so that when it is eventually called, = gnutls_handshake succeeds on the first try instead of first returning = GNUTLS_E_AGAIN, which brings us onto a different code path. > There's been several reports in the last week of TLS not > working on Macos. Has Apple pushed something new, or... did = something > else happen lately in this area on Macos? No, I've been harassed by this bug for quite some time but only now = decided to dig deeper. Most likely it's just a matter of different = timing that the process/TLS system doesn't cope with. First, when the `url-http` call returns we have a Lisp_Process with gnutls_p =3D true gnutls_boot_parameters =3D non-nil gnutls_initstage =3D GNUTLS_STAGE_HANDSHAKE_TRIED (8) and its file descriptor has a corresponding fd_callback_data with flags =3D FOR_WRITE | NON_BLOCKING_CONNECT_FD because the asynchronous connect call has not yet been completed. In the GOOD case (without busy-wait), `wait_reading_process_output` gets = called right away (because Emacs has nothing else to do) and = gnutls_try_handshake initially fails with E_AGAIN but p->outfd becomes = writable so `delete_write_fd` is called to zero the fd_callback_data = flags, and when the handshake eventually succeeds, the sentinel is = called with the "open\n" event. In the BAD case (with busy-wait), the TLS handshake succeeds right away = while the descriptor flags still has NON_BLOCKING_CONNECT_FD set, so the = sentinel isn't called. Does this jog any memories?