Subject: 28.0.50; Closing Gnus server then searching it results in unrecoverable breakage

From: Eric Abrahamsen <[email-masked]>
Date: Tue, 25 Aug 2020 11:12:34 -0700

While fooling around with dbus and server closing, I discovered that the
"closed" state is a bit fragile: I close a server (in this case a
localhost IMAP server) then immediately try to search it, and instead of
the server opening, or me getting a polite error message, I get the
error at the bottom of this report.

That error is then permanent, the server can't be re-opened. Not only
that, when I `gnus-group-restart' the error persists, AND infects my
second IMAP server on localhost, though I guess that's to be expected.
Gnus has to be explicitly quit and then restarted in order to recover.

I note that, in `nnimap-open-server', when I'm trying to open a server
that was closed, the DEFS parameter is populated. But when we get to
`nnoo-change-server', none of the global nnimap-* variables get set
correctly: nnimap-stream should be 'network, but it's 'undecided, which
is why the backtrace below shows failure on an attempted ssl connection.

If I try to open a server that's already open, the DEFS parameter is
nil, but after we reach the `nnoo-change-server' call, all the nnimap-*
vars are set correctly.

That's as far as I've gotten now. I will continue debugging this, but
I'm hanging it here first to remind myself, and in case anyone else
wants to take a whack at it.

Debugger entered--Lisp error: (error "NPR/imaps Name or service not known")
  make-network-process(:name "*nnimap*" :buffer #<buffer  *nnimap NPR nil  *nntpd**> :host "NPR" :service "imaps" :nowait nil :tls-parameters nil :coding nil)
  open-network-stream("*nnimap*" #<buffer  *nnimap NPR nil  *nntpd**> "NPR" "imaps" :nowait nil :tls-parameters nil :coding nil)
  open-gnutls-stream("*nnimap*" #<buffer  *nnimap NPR nil  *nntpd**> "NPR" "imaps" (:type ssl :warn-unless-encrypted t :return-list t :shell-command "ssh %s imapd" :capability-command "1 CAPABILITY\15\n" :always-query-capabilities t :end-of-command "\15\n" :success " OK " :starttls-function #f(compiled-function (capabilities) #<bytecode -0xeb17a16a56719de>)))
  network-stream-open-tls("*nnimap*" #<buffer  *nnimap NPR nil  *nntpd**> "NPR" "imaps" (:type ssl :warn-unless-encrypted t :return-list t :shell-command "ssh %s imapd" :capability-command "1 CAPABILITY\15\n" :always-query-capabilities t :end-of-command "\15\n" :success " OK " :starttls-function #f(compiled-function (capabilities) #<bytecode -0xeb17a16a56719de>)))
  open-network-stream("*nnimap*" #<buffer  *nnimap NPR nil  *nntpd**> "NPR" "imaps" :type ssl :warn-unless-encrypted t :return-list t :shell-command "ssh %s imapd" :capability-command "1 CAPABILITY\15\n" :always-query-capabilities t :end-of-command "\15\n" :success " OK " :starttls-function #f(compiled-function (capabilities) #<bytecode -0xeb17a16a56719de>))
  nnimap-open-connection-1(#<buffer  *nntpd*>)
  nnimap-open-connection(#<buffer  *nntpd*>)
  nnimap-open-server("NPR" nil nil)
  nnimap-change-group("INBOX" "NPR")
  #f(compiled-function (group) #<bytecode -0x1990b256ae59c812>)("nnimap+NPR:INBOX")
  mapcar(#f(compiled-function (group) #<bytecode -0x1990b256ae59c812>) ("nnimap+NPR:INBOX"))
  nnir-run-imap(((query . "body \"searchy\"")) "nnimap:NPR" ("nnimap+NPR:INBOX"))