all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#54384: 29.0.50; shell-resync-dirs failed to work
@ 2022-03-14 13:56 Zhiwei Chen
  2022-03-17 13:50 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Zhiwei Chen @ 2022-03-14 13:56 UTC (permalink / raw)
  To: 54384

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#54384: 29.0.50; shell-resync-dirs failed to work
  2022-03-14 13:56 bug#54384: 29.0.50; shell-resync-dirs failed to work Zhiwei Chen
@ 2022-03-17 13:50 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-17 13:50 UTC (permalink / raw)
  To: Zhiwei Chen; +Cc: 54384

Zhiwei Chen <condy0919@gmail.com> writes:

> 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.

I've now fixed this in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-17 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-14 13:56 bug#54384: 29.0.50; shell-resync-dirs failed to work Zhiwei Chen
2022-03-17 13:50 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.