From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#47861: Starting `jsonrpc-process-connection' over Tramp fails if the process writes to stderr Date: Sat, 17 Apr 2021 20:53:37 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37678"; mail-complaints-to="usenet@ciao.gmane.io" To: 47861@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 18 05:54:10 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 1lXyVd-0009gD-AP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Apr 2021 05:54:09 +0200 Original-Received: from localhost ([::1]:38900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXyVc-0005KP-Dj for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Apr 2021 23:54:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXyVW-0005K9-7s for bug-gnu-emacs@gnu.org; Sat, 17 Apr 2021 23:54:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lXyVV-0004jn-VK for bug-gnu-emacs@gnu.org; Sat, 17 Apr 2021 23:54:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lXyVV-00009G-U2 for bug-gnu-emacs@gnu.org; Sat, 17 Apr 2021 23:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Apr 2021 03:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47861 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1618718034554 (code B ref -1); Sun, 18 Apr 2021 03:54:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Apr 2021 03:53:54 +0000 Original-Received: from localhost ([127.0.0.1]:45022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXyVN-00008r-8k for submit@debbugs.gnu.org; Sat, 17 Apr 2021 23:53:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:40512) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXyVL-00008i-JQ for submit@debbugs.gnu.org; Sat, 17 Apr 2021 23:53:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXyVL-0005Id-Ax for bug-gnu-emacs@gnu.org; Sat, 17 Apr 2021 23:53:51 -0400 Original-Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:39908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lXyVI-0004ZC-Pp for bug-gnu-emacs@gnu.org; Sat, 17 Apr 2021 23:53:51 -0400 Original-Received: by mail-pg1-x52a.google.com with SMTP id s22so801101pgk.6 for ; Sat, 17 Apr 2021 20:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=VVK0o0Oa2671Wrkt3iTNFTxbj6ubqJxRB5eD9zUChjs=; b=s1Et056E9vOxxiWIj/O7BVPA5SmAOJJ4VsPN714G75ht72wXB8Gmts+41nLwgGhJEa s56oSqoJtn0obG53u9ZnIL0GGRppoygShwMG7HPw0+4qpbh8mpN1p/H829yY9+ugCoXf jzxDV1q59DnxtvyDta/ERNgJI1Vu7+Ju3/69qitlVLQgPZfrWQBAEZ2NBEjkVIva4BOt MYeYnsS10ASY6QrobCXprw/D1v7gpAID2iTAPW29OgDj+1eK7tUK7ppNNWnsqDispwn4 0xJFjVvRUR2e8U13DYyvxymHYKPmMIA6n23WNU3DQV+ROsHgiCxWfN1S5SEwUEImgQbe JtLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=VVK0o0Oa2671Wrkt3iTNFTxbj6ubqJxRB5eD9zUChjs=; b=oEhqBJmKVZtSZg7NuUBHiG85BIhy+VMNN10AxkpEMop44q3EbkBHdnjKL+qVPJI/UX EjeRA1wRGZJhfdYCUfiCixOHOeOvwa/nuB9Cs1CD/+qh3LVGeH+Yf0BuD/vfzZPomcyU iqQ+sUBRnIxv3vo/JFmDtp7+ry4akduAYgDonYEuITrKQ3oR0f+pkbDd4lL9kK4hHUmm CVryt8oT8wdIbNbnwmmHh7gXSUR/rp5bgoTceodwosXpUdU+zclYFU7algch/Xl9b+Ej InlyARbE5Jamfhe/GGazsLUq73Zds6SLu0GsKlZ1YH1vlUVh8SpyucG9DrBvffbxroiq BeRg== X-Gm-Message-State: AOAM5338fakKPxc91InpPi6uxy9IlMtw4RqHXjy+xp71gnonf2J7wwQT TC3K4HKjeI8v4PLnMPQy63wJ6T2hE7ZEGk0WVPH55DgMik8= X-Google-Smtp-Source: ABdhPJzmPMpue8j0yytm8ubAYfvzuiXrh0bwsfe7UYsBTsyWhmrPuKe4732JKX0asspMxAFZiHEOU8hFda1NZ4XQk+s= X-Received: by 2002:a63:f962:: with SMTP id q34mr5829343pgk.22.1618718026650; Sat, 17 Apr 2021 20:53:46 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=jporterbugs@gmail.com; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:204289 Archived-At: When starting a `jsonrpc-process-connection' over Tramp, if the process writes to stderr, Emacs (usually) fails with `Wrong type argument: "inserted-chars 204"'. I'm able to reproduce this pretty consistently when connecting from an MS Windows client to a Linux server; however, this may apply to other platform combinations as well. Mysteriously, it works fine about 1 in 10 times, though I haven't been able to decipher why. This is a reduced test case from an eglot issue that prevents users from using eglot with clangd over Tramp (or likely any LSP server that writes to stderr): . Michael Albinus has a workaround for this for the next version of Tramp (2.5.0.4, I believe), but suggested I file an issue here to help find a more-permanent solution. The following recipe reproduces the issue for me on both Emacs 27.2 and the prebuilt Emacs 28 snapshot from 2021-01-15. `jsonrpc-minimal' is a cut-down version of `eglot--connect'. Note that this test tries to run `clangd', but any executable that writes to stderr on startup should reproduce this issue (including a nonexistent executable). After running "emacs -Q": ----------[ Eval the following ]---------- ;; Optional: disable ControlMaster if using ssh on Win32; it doesn't work there. (require 'tramp) (setq tramp-use-ssh-controlmaster-options nil) (require 'jsonrpc) (defun jsonrpc-minimal () (interactive) (make-instance 'jsonrpc-process-connection :name "jsonrpc-minimal" :process (lambda () (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t)))) ----------[ End ]---------- Then run `C-x C-f /sshx:server:~/path/to/file.txt RET' followed by `M-x jsonrpc-minimal'. (Other Tramp methods such as plink should also reproduce this issue.) If `debug-on-error' is set, I get the following backtrace: ----------[ Begin backtrace ]---------- signal(wrong-type-argument ("inserted-chars 204")) tramp-signal-hook-function(wrong-type-argument ("inserted-chars 204")) signal(wrong-type-argument ("inserted-chars 204")) tramp-handle-insert-file-contents("/sshx:server:/tmp/tramp.lLZT4H" nil nil nil nil) apply(tramp-handle-insert-file-contents ("/sshx:server:/tmp/tramp.lLZT4H" nil nil nil nil)) tramp-sh-file-name-handler(insert-file-contents "/sshx:server:/tmp/tramp.lLZT4H" nil nil nil nil) apply(tramp-sh-file-name-handler insert-file-contents ("/sshx:server:/tmp/tramp.lLZT4H" nil nil nil nil)) tramp-file-name-handler(insert-file-contents "/sshx:server:/tmp/tramp.lLZT4H" nil nil nil nil) insert-file-contents("/sshx:server:/tmp/tramp.lLZT4H" nil nil nil nil) insert-file-contents-literally("/sshx:server:/tmp/tramp.lLZT4H") tramp-sh-handle-make-process(:name "jsonrpc-minimal" :command ("sh" "-c" "stty raw > /dev/null; clangd") :connection-type pipe :coding utf-8-emacs-unix :noquery t :stderr # :file-handler t) apply(tramp-sh-handle-make-process (:name "jsonrpc-minimal" :command ("sh" "-c" "stty raw > /dev/null; clangd") :connection-type pipe :coding utf-8-emacs-unix :noquery t :stderr # :file-handler t)) tramp-sh-file-name-handler(make-process :name "jsonrpc-minimal" :command ("sh" "-c" "stty raw > /dev/null; clangd") :connection-type pipe :coding utf-8-emacs-unix :noquery t :stderr # :file-handler t) apply(tramp-sh-file-name-handler make-process (:name "jsonrpc-minimal" :command ("sh" "-c" "stty raw > /dev/null; clangd") :connection-type pipe :coding utf-8-emacs-unix :noquery t :stderr # :file-handler t)) tramp-file-name-handler(make-process :name "jsonrpc-minimal" :command ("sh" "-c" "stty raw > /dev/null; clangd") :connection-type pipe :coding utf-8-emacs-unix :noquery t :stderr # :file-handler t) make-process(:name "jsonrpc-minimal" :command ("sh" "-c" "stty raw > /dev/null; clangd") :connection-type pipe :coding utf-8-emacs-unix :noquery t :stderr # :file-handler t) (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t))() #f(compiled-function (cl--cnm conn slots) #)(#f(compiled-function (&rest cnm-args) #) # (:name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t)))) apply(#f(compiled-function (cl--cnm conn slots) #) #f(compiled-function (&rest cnm-args) #) (# (:name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t))))) #f(compiled-function (&rest args) #)(# (:name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t)))) apply(#f(compiled-function (&rest args) #) # (:name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t)))) initialize-instance(# (:name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t)))) #f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #)(jsonrpc-process-connection :name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t))) apply(#f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #) jsonrpc-process-connection (:name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t)))) make-instance(jsonrpc-process-connection :name "jsonrpc-minimal" :process (closure (t) nil (make-process :name "jsonrpc-minimal" :command '("sh" "-c" "stty raw > /dev/null; clangd") :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create "*jsonrpc-minimal stderr*") :file-handler t))) jsonrpc-minimal() funcall-interactively(jsonrpc-minimal) call-interactively(jsonrpc-minimal record nil) command-execute(jsonrpc-minimal record) execute-extended-command(nil "jsonrpc-minimal" "jsonrpc-minimal") funcall-interactively(execute-extended-command nil "jsonrpc-minimal" "jsonrpc-minimal") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) ----------[ End backtrace ]---------- ----------[ Begin Emacs debug info ]---------- In GNU Emacs 28.0.50 (build 1, x86_64-w64-mingw32) of 2021-01-15 built on CIRROCUMULUS Repository revision: f45be48ddbde00610e1e08fca6590dcf24a4e1b5 Repository branch: master Windowing system distributor 'Microsoft Corp.', version 10.0.19041 System Description: Microsoft Windows 10 Pro (v10.0.2004.19041.928) Configured using: 'configure --without-dbus --without-compress-install -C 'CFLAGS=-O2 -static -g3' PKG_CONFIG_PATH=/mingw64/lib/pkgconfig' Configured features: ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XPM ZLIB Important settings: value of $LANG: ENU locale-coding-system: cp1252 Major mode: Fundamental Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils mule-util help-fns radix-tree cl-print cus-start cus-load vc-hg vc-git diff-mode easy-mmode vc-bzr cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs tramp-cache tramp-sh jsonrpc ert pp ewoc debug backtrace help-mode easymenu find-func pcase warnings tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat shell pcomplete comint ansi-color ring parse-time iso8601 format-spec auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map seq byte-opt gv bytecomp byte-compile cconv time-date subr-x cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 148954 7276) (symbols 48 13698 1) (strings 32 40410 1316) (string-bytes 1 1461011) (vectors 16 21458) (vector-slots 8 300360 13838) (floats 8 55 160) (intervals 56 2822 0) (buffers 984 18)) ----------[ End Emacs debug info ]----------