[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#54384: 29.0.50; shell-resync-dirs failed to work
From: |
Zhiwei Chen |
Subject: |
bug#54384: 29.0.50; shell-resync-dirs failed to work |
Date: |
Mon, 14 Mar 2022 21:56:58 +0800 |
How to reproduce:
emacs -Q
M-x shell RET
M-x shell-resync-dirs RET
Then Emacs will be unresponsive. Fortunately, C-g can quit the function.
Before quitting, it's able to trace Emacs via perf.
#+begin_src sh
sudo perf trace -p $(pidof emacs)
#+end_src
The output tells Emacs is checking whether a path is directory, but it returns
false. See the logs below.
#+begin_src text
1898.605 ( 0.003 ms): emacs/889479 openat(dfd: CWD, filename: 0x5569b9323b80,
flags: RDONLY|CLOEXEC|DIRECTORY|PATH) = -1 ENOENT (No such file or directory)
1898.623 ( 0.003 ms): emacs/889479 openat(dfd: CWD, filename: 0x5569b9323c50,
flags: RDONLY|CLOEXEC|DIRECTORY|PATH) = -1 ENOENT (No such file or directory)
1898.639 ( 0.002 ms): emacs/889479 openat(dfd: CWD, filename: 0x5569b9323d20,
flags: RDONLY|CLOEXEC|DIRECTORY|PATH) = -1 ENOENT (No such file or directory)
1898.656 ( 0.003 ms): emacs/889479 openat(dfd: CWD, filename: 0x5569b9323df0,
flags: RDONLY|CLOEXEC|DIRECTORY|PATH) = -1 ENOENT (No such file or directory)
1898.673 ( 0.002 ms): emacs/889479 openat(dfd: CWD, filename: 0x5569b9323ec0,
flags: RDONLY|CLOEXEC|DIRECTORY|PATH) = -1 ENOENT (No such file or directory)
1898.689 ( 0.002 ms): emacs/889479 openat(dfd: CWD, filename: 0x5569b9323f90,
flags: RDONLY|CLOEXEC|DIRECTORY|PATH) = -1 ENOENT (No such file or directory)
#+end_src
Since I'm using zsh, `shell-resync-dirs' will send "dirs -l" to zsh process,
then grab and parse the output.
* Defect 1
After this while loop
https://github.com/emacs-mirror/emacs/blob/f8cc706fb3d1ba30715c09aac9654ba08aeeb5c9/lisp/shell.el#L1072-L1074,
the value of `dlsl` is '("-l" "" "dirs"), which means `shell-resync-dirs''
failed to grab/parse the output of `dirs -l'.
* Defect 2
The while loop
https://github.com/emacs-mirror/emacs/blob/f8cc706fb3d1ba30715c09aac9654ba08aeeb5c9/lisp/shell.el#L1078-L1092
can be infinite.
When an element of `dlsl' doesn't exist, `file-directory-p' returns false, then
no element of `dlsl' will be poped. An unintentional looping is happening.
--
Zhiwei Chen
- bug#54384: 29.0.50; shell-resync-dirs failed to work,
Zhiwei Chen <=