From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mike Kazantsev Newsgroups: gmane.emacs.bugs Subject: bug#31901: Incorrect make-network-process + nowait state handling for non-existing unix sockets in emacs-26.1 Date: Tue, 19 Jun 2018 10:43:51 +0500 Message-ID: <20180619104351.41e4e3d1@malediction> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1529415499 20648 195.159.176.226 (19 Jun 2018 13:38:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 19 Jun 2018 13:38:19 +0000 (UTC) To: 31901@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 19 15:38:14 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fVGpn-0005FD-OE for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Jun 2018 15:38:11 +0200 Original-Received: from localhost ([::1]:42666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVGrv-0001kv-40 for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Jun 2018 09:40:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVGrf-0001eL-8P for bug-gnu-emacs@gnu.org; Tue, 19 Jun 2018 09:40:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVGrc-0003Ym-4Y for bug-gnu-emacs@gnu.org; Tue, 19 Jun 2018 09:40:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVGrb-0003Yi-Vi for bug-gnu-emacs@gnu.org; Tue, 19 Jun 2018 09:40:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fVGrb-0000RM-Ly for bug-gnu-emacs@gnu.org; Tue, 19 Jun 2018 09:40:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mike Kazantsev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Jun 2018 13:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31901 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15294155521625 (code B ref -1); Tue, 19 Jun 2018 13:40:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Jun 2018 13:39:12 +0000 Original-Received: from localhost ([127.0.0.1]:56037 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fVGql-0000Q8-Nn for submit@debbugs.gnu.org; Tue, 19 Jun 2018 09:39:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fV9R4-0004Rd-PJ for submit@debbugs.gnu.org; Tue, 19 Jun 2018 01:44:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV9Qy-00084m-Cw for submit@debbugs.gnu.org; Tue, 19 Jun 2018 01:44:05 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43529) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fV9Qy-00084f-9m for submit@debbugs.gnu.org; Tue, 19 Jun 2018 01:44:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV9Qw-00034J-VE for bug-gnu-emacs@gnu.org; Tue, 19 Jun 2018 01:44:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV9Qv-00084A-Qf for bug-gnu-emacs@gnu.org; Tue, 19 Jun 2018 01:44:03 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV9Qv-000844-Mg for bug-gnu-emacs@gnu.org; Tue, 19 Jun 2018 01:44:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52728) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fV9Qu-0003Sn-Uc for bug-emacs@gnu.org; Tue, 19 Jun 2018 01:44:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV9Qp-00082X-Ri for bug-emacs@gnu.org; Tue, 19 Jun 2018 01:44:00 -0400 Original-Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:36844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV9Qp-000828-JK for bug-emacs@gnu.org; Tue, 19 Jun 2018 01:43:55 -0400 Original-Received: by mail-lf0-x231.google.com with SMTP id n24-v6so12431902lfh.3 for ; Mon, 18 Jun 2018 22:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version :content-transfer-encoding; bh=6N94k3Aus1O4ERLv9Hbk9yj48I2z32GQvPht/9i2Wes=; b=fkOrMAWlCJ3rBNT7pwPZ8MGd3kq5GwoYQijsmdFOKO3WDcC8dNiZbkAkdPiI/DX5VC CkESXLw9aH05l4tix2FRWeFz5LKNb8pD3KbruBE5JsBlZs2JKpLHOzAaOKpzWjeSsG7Z tRRXZkoGQlkcroGfZZWsxJ8NP6r7EI7Y3bZewPX+c+MsEONZyUW1zJaunhyj86toEfnA F2ueFKtIutB0WFU/yuvHCwy4PLEx5EOoH3gnf9aLJvyh3wn66W7wlhDWbm89wMPOiiLl 8v5xeRo5ANGmVgGB3JNPOS3mRs4sGMLCZCOJisJvFsgnTo1CMPMzAZSBkMdW+wssC2i8 NBJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-transfer-encoding; bh=6N94k3Aus1O4ERLv9Hbk9yj48I2z32GQvPht/9i2Wes=; b=oYlogm/jEiMsyE8kbU09hhGeaTMsm7YAKXtuWbXZNYyZQIAhHpebZlFH85aSauA6bp 92/X+s8+pYgXEndkQf4L0yaNEKFXgmicVseEq4XnbArqVCCA2cFPBDCz2TlFsIzqxvPa nAt21mzI4bcOHE/k5TkH3v/f2bnGhFfDEQgyaS1KxNIyckCc7bL9Kk9WJaxZy0qeOxeW N3Xzd727TTYgknElBPAZh1+mttkKyJoSehtewMa5W6f4M+CaNqie/sBW72fFrw18DJuX s9S1qyFq9hMFxjKrE96RYaVK/8eHC2KKA6v0NblZxW6kyuW/I6p5mZA1523VjyO1gfvN h2Dg== X-Gm-Message-State: APt69E28hfwtmJq5u+jlEwhiOuUox9CsYYAbivFijvNvpZJtxJ0q75fl lhUIMPrMocJ9fo5oYCuv+NTskuQm X-Google-Smtp-Source: ADUXVKI0SM/ESR0F6a0nBAIUuGN+gQUKc/HeTDSK6vS8LQ5M0844lRIDDzJ/cEeODCEgU8a48namVg== X-Received: by 2002:a2e:8184:: with SMTP id e4-v6mr10246266ljg.93.1529387033845; Mon, 18 Jun 2018 22:43:53 -0700 (PDT) Original-Received: from malediction ([46.48.96.28]) by smtp.gmail.com with ESMTPSA id j78-v6sm3011473ljb.10.2018.06.18.22.43.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 22:43:53 -0700 (PDT) X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Tue, 19 Jun 2018 09:39:10 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147627 Archived-At: Description: Running (make-network-process ... :family 'local :nowait t) with non-exising socket hangs forever in "open" state without ever calling sentinel function. 100% reproducible on emacs-26.1 in current Archlinux OS. ==== How to reproduce: Run following s-expressions from lisp-interaction-mode buffer in the same sequence: (defun unix-socket-test-func (proc ev) (message "unix-socket-test: %s %s" proc ev)) (defvar socket) (setq socket (make-network-process :name "unix-socket-test" :family 'local :service "/tmp/does-not-exist.sock" :nowait t :coding '(utf-8 . utf-8) :buffer (get-buffer-create "some-ipc-buffer") :noquery t :filter #'unix-socket-test-func :sentinel #'unix-socket-test-func)) (process-live-p socket) (process-status socket) (delete-process socket) Note - assuming that /tmp/does-not-exist.sock does not exist on the filesystem. ==== Expected result: One or more of: - Message "unix-socket-test: failed" or some similar failure is reported by the sentinel function. - Maybe "open" then "failed" states reported, in case socket() call is treated as 'open before connect() is issued. - "socket" variable is set to nil, as it was with ":nowait t" before emacs-26, due to such simple and instant error. - (process-live-p socket) reports nil when run few seconds after make-network-process call. - (process-status socket) reports some kind of failed state, not 'open. None of this happens. ==== Actual result: - socket process is created and stuck forever in 'open state. - strace on emacs process (monitoring syscalls) show this syscall sequence happening immediately when make-network-process call is made: [pid 31590] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 21 [pid 31590] connect(21, {sa_family=AF_UNIX, sun_path="/tmp/does-not-exist.sock"}, 110) = -1 ENOENT (No such file or directory) [pid 31590] close(21) = 0 - Function passed as :sentinel to make-network-process is never called with any state - neither 'open nor 'failed. - (process-live-p socket) returns non-nil result for process associated with socket that is actually closed, and was closed immediately on connect, without any indication of that in elisp code. - (process-status socket) returns 'open, even though it never sent 'open status to sentinel function, nor is socket actually open at that point. It never succeeded at connecting to anything, in fact. Same thing happens with socket that nothing is listening on, except strace there gives different error on connect(): [pid 31590] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 21 [pid 31590] connect(21, {sa_family=AF_UNIX, sun_path="/tmp/does-not-exist.sock"}, 110) = -1 ECONNREFUSED (Connection refused) [pid 31590] close(21) This makes using unix sockets with emacs correctly and efficiently very hard, if not impossible, as it there's no way to tell if it is stuck connecting or failed except setting some kind of timeout on sentinel response. As far as I can tell, this is not documented behavior, definitely unexpected, breaks all old code that used unix sockets, and probably unintentional, i.e. a bug. Apart from mentioned Archlinux setup, symptoms of the same issue were also reported on EMMS (emacs multimedia system) mailing list with emacs-26 recently on Ubuntu 18.10 pre-release version. Have tried to find exising reports for such - rather basic, it seems - problem, but haven't found any, so not entirely sure if maybe I'm doing something wrong here. Thanks for reading this far and any assistance. -- Mike Kazantsev // fraggod.net