Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-25 Thread Michael Albinus
Version 28.1

Hi Robert,

Robert Pluim  writes:

> Michael> Michael Albinus  writes:
> Michael> Hi Robert,
>
> >>> Thanks for that. It works for me now with emacs-27 (but not on 
> master).
> >>
> >> Thanks for the feedback. My patch is dedicated to the emacs-27 branch
> >> only; once I get confirmation from Rob or Thomas, I'll push it, and 
> I'll
> >> prepare a similar patch for master.
> >>
> >> One step after the other.
>
> Michael> The latest commit shall work in master branch.
>
> Confirmed. Thanks Michael.

Thanks for the confirmation. Nobody else has commented, so I'm closing 
bug#48476.

> Robert

Best regards, Michael.



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-25 Thread Robert Pluim
> On Sun, 23 May 2021 13:42:32 +0200, Michael Albinus 
>  said:

Michael> Michael Albinus  writes:
Michael> Hi Robert,

>>> Thanks for that. It works for me now with emacs-27 (but not on master).
>> 
>> Thanks for the feedback. My patch is dedicated to the emacs-27 branch
>> only; once I get confirmation from Rob or Thomas, I'll push it, and I'll
>> prepare a similar patch for master.
>> 
>> One step after the other.

Michael> The latest commit shall work in master branch.

Confirmed. Thanks Michael.

Robert
-- 



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-23 Thread Michael Albinus
Michael Albinus  writes:

Hi Robert,

>> Thanks for that. It works for me now with emacs-27 (but not on master).
>
> Thanks for the feedback. My patch is dedicated to the emacs-27 branch
> only; once I get confirmation from Rob or Thomas, I'll push it, and I'll
> prepare a similar patch for master.
>
> One step after the other.

The latest commit shall work in master branch.

>> Robert

Best regards, Michael.



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-20 Thread Robert Pluim
> On Thu, 20 May 2021 15:05:51 +0200, Michael Albinus 
>  said:

Michael> Robert Pluim  writes:
>> Thanks for that. It works for me now with emacs-27 (but not on master).

Michael> Thanks for the feedback. My patch is dedicated to the emacs-27 
branch
Michael> only; once I get confirmation from Rob or Thomas, I'll push it, 
and I'll
Michael> prepare a similar patch for master.

Michael> One step after the other.

No, no, no: I rush ahead testing other stuff so that the person who
knows how the code works (you) doesnʼt have to :-)

Robert
-- 



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-20 Thread Michael Albinus
Robert Pluim  writes:

> Thanks for that. It works for me now with emacs-27 (but not on master).

Thanks for the feedback. My patch is dedicated to the emacs-27 branch
only; once I get confirmation from Rob or Thomas, I'll push it, and I'll
prepare a similar patch for master.

One step after the other.

> Robert

Best regards, Michael.



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-20 Thread Robert Pluim
> On Thu, 20 May 2021 11:24:35 +0200, Michael Albinus 
>  said:

Michael> Robert Pluim  writes:
Michael> Hi Robert,

Michael> The appended patch should fix it. It is towards the emacs-27
Michael> branch. Although there won't be a Tramp 27.3 in the future, Debian 
(and
Michael> other distributions) might patch its distributed Emacs 27.2.
>> 
>> emacs-27 is still looping with that patch:

Michael> Since the changes are in autoloaded functions, you must regenerate
Michael> loaddefs.el, and it must be dumped into Emacs. During my tests, I 
have
Michael> always applied

Michael> # rm lisp/loaddefs.el ; make

Thanks for that. It works for me now with emacs-27 (but not on master).

Robert
-- 



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-20 Thread Michael Albinus
Robert Pluim  writes:

Hi Robert,

> Michael> The appended patch should fix it. It is towards the emacs-27
> Michael> branch. Although there won't be a Tramp 27.3 in the future, 
> Debian (and
> Michael> other distributions) might patch its distributed Emacs 27.2.
>
> emacs-27 is still looping with that patch:

Since the changes are in autoloaded functions, you must regenerate
loaddefs.el, and it must be dumped into Emacs. During my tests, I have
always applied

# rm lisp/loaddefs.el ; make

> Robert

Best regards, Michael.



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-20 Thread Robert Pluim
> On Wed, 19 May 2021 16:22:10 +0200, Michael Albinus 
>  said:

Michael> Michael Albinus  writes:
Michael> Hi,

>>> Michael, this is emacs signalling an error for a recursive load,
>>> apparently forever.
>> 
>> Ahh, thanks. This gives me some ideas for check.

Michael> The appended patch should fix it. It is towards the emacs-27
Michael> branch. Although there won't be a Tramp 27.3 in the future, Debian 
(and
Michael> other distributions) might patch its distributed Emacs 27.2.

emacs-27 is still looping with that patch:

openat(AT_FDCWD, "/home/rpluim/repos/emacs-27/lisp/net/tramp-archive.elc", 
O_RDONLY|O_CLOEXEC) = 14
openat(AT_FDCWD, "/home/rpluim/repos/emacs-27/lisp/net/tramp-archive.elc", 
O_RDONLY|O_CLOEXEC) = 15
openat(AT_FDCWD, "/home/rpluim/repos/emacs-27/lisp/net/tramp-archive.elc", 
O_RDONLY|O_CLOEXEC) = 16
openat(AT_FDCWD, "/home/rpluim/repos/emacs-27/lisp/net/tramp-archive.elc", 
O_RDONLY|O_CLOEXEC) = 17
openat(AT_FDCWD, "/home/rpluim/repos/emacs-27/lisp/net/tramp-archive.elc", 
O_RDONLY|O_CLOEXEC) = 18
openat(AT_FDCWD, "/home/rpluim/repos/emacs-27/lisp/net/tramp-archive.elc", 
O_RDONLY|O_CLOEXEC) = 14

Iʼve not trapped it reliably in gdb yet. master is the same

Robert
-- 



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-19 Thread Michael Albinus
Michael Albinus  writes:

Hi,

>> Michael, this is emacs signalling an error for a recursive load,
>> apparently forever.
>
> Ahh, thanks. This gives me some ideas for check.

The appended patch should fix it. It is towards the emacs-27
branch. Although there won't be a Tramp 27.3 in the future, Debian (and
other distributions) might patch its distributed Emacs 27.2.

>> Robert

Best regards, Michael.

diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index e690687413..a8a1851abb 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -343,8 +343,12 @@ tramp-archive-file-name-handler
 	  (tramp-archive-run-real-handler operation args)))

 ;;;###autoload
-(defalias
-  'tramp-archive-autoload-file-name-handler #'tramp-autoload-file-name-handler)
+(progn (defun tramp-archive-autoload-file-name-handler (operation  args)
+  "Load Tramp archive file name handler, and perform OPERATION."
+  (if tramp-archive-enabled
+  (let ((tramp-archive-autoload t))
+tramp-archive-autoload ; Silence byte compiler.
+(apply #'tramp-autoload-file-name-handler operation args)

 ;;;###autoload
 (progn (defun tramp-register-archive-file-name-handler ()
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 570294e8b9..a81dbaaf69 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2444,6 +2444,8 @@ tramp-completion-file-name-handler
   (tramp-unload-file-name-handlers)
   (if tramp-mode
   (let ((default-directory temporary-file-directory))
+(if (bound-and-true-p tramp-archive-autoload)
+	(load "tramp-archive" 'noerror 'nomessage))
 	(load "tramp" 'noerror 'nomessage)))
   (apply operation args)))



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-17 Thread Michael Albinus
Robert Pluim  writes:

Hi Robert,

> I have a backtrace from gdb that might shed some light.
>
> Michael, this is emacs signalling an error for a recursive load,
> apparently forever.

Ahh, thanks. This gives me some ideas for check.

> Robert

Best regards, Michael.



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-17 Thread Michael Albinus
Lars Ingebrigtsen  writes:

Hi Lars,

>>> My emacs get stuck with 100% cpu when started from a directory ending with
>>> ".tar".

Sure, this is the Tramp archive handler. But it shall be invoked only
when the file name ends with ".tar/" - see the trailing slash.

>>> For example, the following commands trigger the error:
>>> - mkdir test.tar
>>> - cd test.tar
>>> - emacs

Yes. But is this a real scenario?

> I have not tried to debug further, but this strace seems to indicate
> that this might be Tramp-related, so I've added Michael to the CCs --
> perhaps it'll be immediately obvious to him what the problem is.  :-)

Hmm, Tramp shall return with an error message (possibly) or give
up. Will investigate.

Anyway, setting tramp-archive-enabled to nil should mitigate the
problem.

Best regards, Michael.



Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-17 Thread Robert Pluim
> On Mon, 17 May 2021 16:42:33 +0200, Lars Ingebrigtsen  
> said:

Lars> Rob Browning  writes:
>>> My emacs get stuck with 100% cpu when started from a directory ending 
with
>>> ".tar".
>>> 
>>> For example, the following commands trigger the error:
>>> - mkdir test.tar
>>> - cd test.tar
>>> - emacs

Lars> I can reproduce this on Debian/bullseye on the trunk, too -- Emacs 
uses
Lars> 100% CPU and can't be interrupted with `C-g'.

Lars> strace seems to say that it's inflooping like this:

Lars> pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", O_RDONLY|O_CLOEXEC) = 
15
Lars> [pid 70536] fstat(15, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
Lars> [pid 70536] read(15, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 
512) = 512
Lars> [pid 70536] lseek(15, 0, SEEK_SET)  = 0
Lars> [pid 70536] newfstatat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", 
{st_mode=S_IFREG|0644, st_size=24503, ...}, 0) = 0
Lars> [pid 70536] newfstatat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.el", {st_mode=S_IFREG|0644, 
st_size=28504, ...}, 0) = 0
Lars> [pid 70536] fcntl(15, F_GETFL)  = 0x8000 (flags 
O_RDONLY|O_LARGEFILE)
Lars> [pid 70536] fstat(15, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
Lars> [pid 70536] read(15, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 
4096) = 4096
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so", O_RDONLY|O_CLOEXEC) = 
-1 ENOENT (No such file or directory)
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", O_RDONLY|O_CLOEXEC) = 
16
Lars> [pid 70536] fstat(16, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
Lars> [pid 70536] read(16, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 
512) = 512
Lars> [pid 70536] lseek(16, 0, SEEK_SET)  = 0
Lars> [pid 70536] newfstatat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.el", {st_mode=S_IFREG|0644, 
st_size=28504, ...}, 0) = 0
Lars> [pid 70536] fcntl(16, F_GETFL)  = 0x8000 (flags 
O_RDONLY|O_LARGEFILE)
Lars> [pid 70536] fstat(16, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
Lars> [pid 70536] read(16, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 
4096) = 4096
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so", O_RDONLY|O_CLOEXEC) = 
-1 ENOENT (No such file or directory)
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", O_RDONLY|O_CLOEXEC) = 
17
Lars> [pid 70536] fstat(17, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
Lars> [pid 70536] close(17)   = 0
Lars> [pid 70536] close(16)   = 0
Lars> [pid 70536] close(15)   = 0
Lars> [pid 70536] close(14)   = 0
Lars> [pid 70536] close(13)   = 0
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so", O_RDONLY|O_CLOEXEC) = 
-1 ENOENT (No such file or directory)
Lars> [pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)

I have a backtrace from gdb that might shed some light.

Michael, this is emacs signalling an error for a recursive load,
apparently forever. master has the same issue. I set a breakpoint at
lread.c:1366

  {
int load_count = 0;
Lisp_Object tem = Vloads_in_progress;
FOR_EACH_TAIL_SAFE (tem)
  if (!NILP (Fequal (found, XCAR (tem))) && (++load_count > 3))
->  signal_error ("Recursive load", Fcons (found, Vloads_in_progress));
record_unwind_protect (record_load_unwind, Vloads_in_progress);
Vloads_in_progress = Fcons (found, Vloads_in_progress);
  }

and got this backtrace, which implicates
'tramp-archive-autoload-file-name-handler'

Thread 1 "emacs" hit Breakpoint 5, Fload (file=XIL(0x56847f74), 
noerror=XIL(0), nomessage=XIL(0x30), nosuffix=, 
must_suffix=) at lread.c:1366
1366signal_error ("Recursive load", Fcons (found, 
Vloads_in_progress));
(gdb) bt
#0  Fload (file=XIL(0x56847f74), noerror=XIL(0), nomessage=XIL(0x30), 
nosuffix=, must_suffix=)
at lread.c:1366
#1  0x5572be5a in save_match_data_load
(file=XIL(0x56847f74), noerror=noerror@entry=XIL(0), 
nomessage=nomessage@entry=XIL(0x30), 

Bug#988581: bug#48476: Bug#988581: emacs-gtk: Emacs hangs with 100% cpu if started within a current directory that has a name ending with ".tar"

2021-05-17 Thread Lars Ingebrigtsen
Rob Browning  writes:

>> My emacs get stuck with 100% cpu when started from a directory ending with
>> ".tar".
>>
>> For example, the following commands trigger the error:
>> - mkdir test.tar
>> - cd test.tar
>> - emacs

I can reproduce this on Debian/bullseye on the trunk, too -- Emacs uses
100% CPU and can't be interrupted with `C-g'.

strace seems to say that it's inflooping like this:

pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", O_RDONLY|O_CLOEXEC) = 
15
[pid 70536] fstat(15, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
[pid 70536] read(15, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 512) = 512
[pid 70536] lseek(15, 0, SEEK_SET)  = 0
[pid 70536] newfstatat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", 
{st_mode=S_IFREG|0644, st_size=24503, ...}, 0) = 0
[pid 70536] newfstatat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.el", {st_mode=S_IFREG|0644, 
st_size=28504, ...}, 0) = 0
[pid 70536] fcntl(15, F_GETFL)  = 0x8000 (flags O_RDONLY|O_LARGEFILE)
[pid 70536] fstat(15, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
[pid 70536] read(15, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 4096) = 4096
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so", O_RDONLY|O_CLOEXEC) = 
-1 ENOENT (No such file or directory)
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", O_RDONLY|O_CLOEXEC) = 
16
[pid 70536] fstat(16, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
[pid 70536] read(16, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 512) = 512
[pid 70536] lseek(16, 0, SEEK_SET)  = 0
[pid 70536] newfstatat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.el", {st_mode=S_IFREG|0644, 
st_size=28504, ...}, 0) = 0
[pid 70536] fcntl(16, F_GETFL)  = 0x8000 (flags O_RDONLY|O_LARGEFILE)
[pid 70536] fstat(16, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
[pid 70536] read(16, ";ELC\33\0\0\0\n;;; Compiled\n;;; in Ema"..., 4096) = 4096
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so", O_RDONLY|O_CLOEXEC) = 
-1 ENOENT (No such file or directory)
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.elc", O_RDONLY|O_CLOEXEC) = 
17
[pid 70536] fstat(17, {st_mode=S_IFREG|0644, st_size=24503, ...}) = 0
[pid 70536] close(17)   = 0
[pid 70536] close(16)   = 0
[pid 70536] close(15)   = 0
[pid 70536] close(14)   = 0
[pid 70536] close(13)   = 0
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so", O_RDONLY|O_CLOEXEC) = 
-1 ENOENT (No such file or directory)
[pid 70536] openat(AT_FDCWD, 
"/home/larsi/src/emacs/trunk/lisp/net/tramp-archive.so.gz", O_RDONLY|O_CLOEXEC) 
= -1 ENOENT (No such file or directory)

I have not tried to debug further, but this strace seems to indicate
that this might be Tramp-related, so I've added Michael to the CCs --
perhaps it'll be immediately obvious to him what the problem is.  :-)

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