unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: 49449@debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#49449: 28: TLS connection never gets to "open" stage
Date: Tue, 6 Jul 2021 21:12:39 +0200	[thread overview]
Message-ID: <A2F33FB7-B9AA-49E4-A844-98AEE562CE8E@acm.org> (raw)

It seems that the process/TLS apparatus can get into a state where it is unable to ever call the process sentinel "open\n" event; specifically, an async `url-https` does not make forward progress until the connection times out.

This has been observed on macOS in Emacs 28 now and then, and it looks like there is an invariant violation somewhere. To recap:

The "open\n" event is sent to the sentinel in either of two places:

(A) In finish_after_tls_connection, after having successfully called nsm-verify-connection and the condition

  (fd_callback_info[p->outfd].flags & NON_BLOCKING_CONNECT_FD) == 0

being satisfied (process.c:3277).

(B) In wait_reading_process_output, after the descriptor being found writable by `select` and the condition

    NILP (p->gnutls_boot_parameters) && !p->gnutls_p

being satisfied (process.c:5900).

There seems to be a gap in the logic, however: it is perfectly possible for the condition in (A) to fail because the descriptor is still marked nonblocking at that point, and for (B) to fail because gnutls_p=true was set already in gnutls_try_handshake.

Lars, it looks like you wrote at least part of the original logic. Can you see what is going on? It is somewhat complex.

For reference, I'm using the reproduction recipe below; it may or may not exhibit the problem in your particular setup. I'm using gnutls 3.6.15.

(defun busy-wait (s)
  (let ((t0 (current-time)))
    (while (< (time-to-seconds (time-since t0)) s) nil)))

(progn
  (url-http
   #s(url "https" nil nil "elpa.gnu.org" nil "/packages/archive-contents" nil nil t silent t t)
   (lambda (status) (message "callback: status = %S" status))
   '(nil) nil 'tls)
  (busy-wait 1.0))







             reply	other threads:[~2021-07-06 19:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 19:12 Mattias Engdegård [this message]
2021-07-07 19:57 ` bug#49449: 28: TLS connection never gets to "open" stage Lars Ingebrigtsen
2021-07-08  7:59   ` Mattias Engdegård
2021-07-08 12:54     ` Lars Ingebrigtsen
2021-07-08 16:47       ` Mattias Engdegård
2021-07-10 16:27         ` Lars Ingebrigtsen
2021-07-10 16:51           ` Mattias Engdegård
2021-07-10 16:57             ` Lars Ingebrigtsen
2021-07-10 17:07               ` Mattias Engdegård
2021-07-10 18:23               ` Mattias Engdegård
2021-07-10 18:54                 ` Eli Zaretskii
2021-07-10 19:22                   ` Mattias Engdegård
2021-07-10 19:31                     ` Eli Zaretskii
2021-07-10 19:44                       ` Mattias Engdegård
2021-07-11  6:49                         ` Eli Zaretskii
2021-07-11  7:42                           ` Mattias Engdegård
2021-07-11 10:14                             ` Eli Zaretskii
2021-07-11 14:26                               ` Mattias Engdegård
2021-07-11 15:01                                 ` Eli Zaretskii
2021-07-12 14:57                                   ` Mattias Engdegård
2021-07-12 15:02                                     ` Lars Ingebrigtsen
2021-07-13 17:08                                       ` Mattias Engdegård
2021-07-10 20:05                 ` Mattias Engdegård
2021-07-11 11:31                   ` Lars Ingebrigtsen
2021-07-11 11:29                 ` Lars Ingebrigtsen
2021-07-11 14:28                   ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A2F33FB7-B9AA-49E4-A844-98AEE562CE8E@acm.org \
    --to=mattiase@acm.org \
    --cc=49449@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).