unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Bruno Haible <bruno@clisp.org>
Cc: 65324@debbugs.gnu.org, Stefan Kangas <stefankangas@gmail.com>
Subject: bug#65324: "make check" hangs on NetBSD 9.3
Date: Tue, 12 Sep 2023 22:12:18 +0200	[thread overview]
Message-ID: <871qf3qhgd.fsf@gmx.de> (raw)
In-Reply-To: <1784710.DirUC8aPjC@nimes> (Bruno Haible's message of "Tue, 12 Sep 2023 16:31:12 +0200")

[-- Attachment #1: Type: text/plain, Size: 2046 bytes --]

Bruno Haible <bruno@clisp.org> writes:

Hi Bruno,

> Ah, you meant, I made a mistake while applying your patch? Indeed, I had
> not noticed the change from tramp-test-instrument-test-case to
> tramp--test-instrument-test-case. Now I fixed that. Find attached the two
> output files. I truncated the file '*debug tramp mock netbsd93.bruno.haible.de*'
> to 10000 lines, since it starts to repeat itself (modulo time stamps) after
> line 6499.

Thanks, this has told us the story, indeed. The last command Tramp has
sent is

--8<---------------cut here---------------start------------->8---
16:04:12.381001 tramp-send-command (6) # /bin/ls -ild -w /tmp/tramp-testXwo544/foo/\	foo\ bar\ baz\	\@foo\@bar\@baz\@\$foo\$bar\$\$baz\$-foo-bar-baz-\%foo\%bar\%baz\%\&foo\&bar\&baz\&\?foo\?bar\?baz\?\*foo\+bar\*baz\+\'foo\"bar\'baz\"\#foo\~bar\#baz\~\!foo\|bar\!baz\|\:foo\;bar\:baz\;\<foo\>bar\<baz\>\(foo\)bar\(baz\)\[foo\]bar\[baz\]\{foo\}bar\{baz\}/\	foo\ bar\ baz\	\@foo\@bar\@baz\@\$foo\$bar\$\$baz\$-foo-bar-baz-\%foo\%bar\%baz\%\&foo\&bar\&baz\&\?foo\?bar\?baz\?\*foo\+bar\*baz\+\'foo\"bar\'baz\"\#foo\~bar\#baz\~\!foo\|bar\!baz\|\:foo\;bar\:baz\;\<foo\>bar\<baz\>\(foo\)bar\(baz\)\[foo\]bar\[baz\]\{foo\}bar\{baz\}; /bin/ls -lnd -w /tmp/tramp-testXwo544/foo/\	foo\ bar\ baz\	\@foo\@bar\@baz\@\$foo\$bar\$\$baz\$-foo-bar-baz-\%foo\%bar\%baz\%\&foo\&bar\&baz\&\?foo\?bar\?baz\?\*foo\+bar\*baz\+\'foo\"bar\'baz\"\#foo\~bar\#baz\~\!foo\|bar\!baz\|\:foo\;bar\:baz\;\<foo\>bar\<baz\>\(foo\)bar\(baz\)\[foo\]bar\[baz\]\{foo\}bar\{baz\}/\	foo\ bar\ baz\	\@foo\@bar\@baz\@\$foo\$bar\$\$baz\$-foo-bar-baz-\%foo\%bar\%baz\%\&foo\&bar\&baz\&\?foo\?bar\?baz\?\*foo\+bar\*baz\+\'foo\"bar\'baz\"\#foo\~bar\#baz\~\!foo\|bar\!baz\|\:foo\;bar\:baz\;\<foo\>bar\<baz\>\(foo\)bar\(baz\)\[foo\]bar\[baz\]\{foo\}bar\{baz\}
--8<---------------cut here---------------end--------------->8---

Yes, one line. This is too long for your shell. I have modified
tramp-sh.el (see appended), could you pls give it a test?

> Bruno

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 5324 bytes --]

diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index 05cd2778..7b289053 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -1295,43 +1295,93 @@ Operations not mentioned here will be handled by the normal Emacs functions.")

 (defun tramp-do-file-attributes-with-ls (vec localname)
   "Implement `file-attributes' for Tramp files using the ls(1) command."
-  (let (symlinkp dirp
+  (let ((optimized (tramp-compat-length< localname 255))
+	symlinkp dirp
 	res-inode res-filemodes res-numlinks
 	res-uid-string res-gid-string res-uid-integer res-gid-integer
 	res-size res-symlink-target res-context)
     (tramp-message vec 5 "file attributes with ls: %s" localname)
-    ;; We cannot send both commands combined, it could exceed NAME_MAX
-    ;; or PATH_MAX.  Happened on macOS, for example.
-    (when (tramp-send-command-and-check
-           vec
-           (format "cd %s && (%s %s || %s -h %s)"
-		   (tramp-shell-quote-argument
-		    (tramp-run-real-handler
-		     #'file-name-directory (list localname)))
-		   (tramp-get-file-exists-command vec)
-		   (if (string-empty-p (file-name-nondirectory localname))
-		       "."
-                     (tramp-shell-quote-argument
-		      (file-name-nondirectory localname)))
-                   (tramp-get-test-command vec)
-		   (if (string-empty-p (file-name-nondirectory localname))
-		       "."
-                     (tramp-shell-quote-argument
-		      (file-name-nondirectory localname)))))
-      (tramp-send-command
-       vec
-       (format "%s -ild %s %s; %s -lnd%s %s %s"
-               (tramp-get-ls-command vec)
-               ;; On systems which have no quoting style, file names
-               ;; with special characters could fail.
-               (tramp-sh--quoting-style-options vec)
-               (tramp-shell-quote-argument localname)
-               (tramp-get-ls-command vec)
-	       (if (tramp-remote-selinux-p vec) "Z" "")
-               ;; On systems which have no quoting style, file names
-               ;; with special characters could fail.
-               (tramp-sh--quoting-style-options vec)
-               (tramp-shell-quote-argument localname)))
+    ;; We cannot send both commands combined, it could exceed
+    ;; NAME_MAX, LINE_MAX or PATH_MAX.  Happened on macOS or NetBSD,
+    ;; for example.  As a heuristic, we check whether the file name is
+    ;; less than 255.  See Bug#65324.
+    (when (if optimized
+	      (tramp-send-command-and-check
+	       vec
+	       (format "cd %s && (%s %s || %s -h %s)"
+		       (tramp-shell-quote-argument
+			(tramp-run-real-handler
+			 #'file-name-directory (list localname)))
+		       (tramp-get-file-exists-command vec)
+		       (if (string-empty-p (file-name-nondirectory localname))
+			   "."
+			 (tramp-shell-quote-argument
+			  (file-name-nondirectory localname)))
+		       (tramp-get-test-command vec)
+		       (if (string-empty-p (file-name-nondirectory localname))
+			   "."
+			 (tramp-shell-quote-argument
+			  (file-name-nondirectory localname)))))
+
+	    ;; Send single commands.
+	    (or (tramp-send-command-and-check
+		 vec
+		 (format "cd %s && %s %s"
+			 (tramp-shell-quote-argument
+			  (tramp-run-real-handler
+			   #'file-name-directory (list localname)))
+			 (tramp-get-file-exists-command vec)
+			 (if (string-empty-p (file-name-nondirectory localname))
+			     "."
+			   (tramp-shell-quote-argument
+			    (file-name-nondirectory localname)))))
+		(tramp-send-command-and-check
+		 vec
+		 (format "%s -h %s"
+			 (tramp-get-test-command vec)
+			 (if (string-empty-p (file-name-nondirectory localname))
+			     "."
+			   (tramp-shell-quote-argument
+			    (file-name-nondirectory localname)))))))
+
+      (if optimized
+	  (tramp-send-command
+	   vec
+	   (format "%s -ild %s %s; %s -lnd%s %s %s"
+		   (tramp-get-ls-command vec)
+		   ;; On systems which have no quoting style, file
+		   ;; names with special characters could fail.
+		   (tramp-sh--quoting-style-options vec)
+		   (tramp-shell-quote-argument localname)
+		   (tramp-get-ls-command vec)
+		   (if (tramp-remote-selinux-p vec) "Z" "")
+		   ;; On systems which have no quoting style, file
+		   ;; names with special characters could fail.
+		   (tramp-sh--quoting-style-options vec)
+		   (tramp-shell-quote-argument localname)))
+
+	;; Send single commands.
+	(with-current-buffer (tramp-get-buffer vec)
+	  (tramp-send-command
+	   vec
+	   (format "%s -ild %s %s"
+		   (tramp-get-ls-command vec)
+		   ;; On systems which have no quoting style, file
+		   ;; names with special characters could fail.
+		   (tramp-sh--quoting-style-options vec)
+		   (tramp-shell-quote-argument localname)))
+	  (narrow-to-region (point-max) (point-max))
+	  (tramp-send-command
+	   vec
+	   (format "%s -lnd%s %s %s"
+		   (tramp-get-ls-command vec)
+		   (if (tramp-remote-selinux-p vec) "Z" "")
+		   ;; On systems which have no quoting style, file
+		   ;; names with special characters could fail.
+		   (tramp-sh--quoting-style-options vec)
+		   (tramp-shell-quote-argument localname)))
+	  (widen)))
+
       ;; Parse `ls -l' output ...
       (with-current-buffer (tramp-get-buffer vec)
         (when (> (buffer-size) 0)

  reply	other threads:[~2023-09-12 20:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 22:02 bug#65324: "make check" hangs on NetBSD 9.3 Bruno Haible
2023-09-01 20:23 ` Stefan Kangas
2023-09-02 11:24   ` Michael Albinus
2023-09-02 11:33     ` Bruno Haible
2023-09-02 11:54       ` Michael Albinus
2023-09-02 12:16         ` Bruno Haible
2023-09-02 14:08           ` Michael Albinus
2023-09-02 15:25             ` Bruno Haible
2023-09-02 16:30               ` Michael Albinus
2023-09-02 17:55                 ` Bruno Haible
2023-09-04  9:52                   ` Michael Albinus
2023-09-04 10:19                     ` Bruno Haible
2023-09-04 10:28                       ` Michael Albinus
2023-09-04 10:39                         ` Bruno Haible
2023-09-05 17:56                           ` Michael Albinus
2023-09-11 12:26                             ` Michael Albinus
2023-09-12 14:31                               ` Bruno Haible
2023-09-12 20:12                                 ` Michael Albinus [this message]
2023-09-12 23:03                                   ` Bruno Haible
2023-09-13 14:34                                     ` Michael Albinus
2023-09-13 19:17                                       ` Bruno Haible
2023-09-14 12:51                                         ` Michael Albinus
2023-09-22 18:06                                           ` Michael Albinus

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=871qf3qhgd.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=65324@debbugs.gnu.org \
    --cc=bruno@clisp.org \
    --cc=stefankangas@gmail.com \
    /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).