Subject: bug#45518: Ctrl-G Fails to Interrupt Hung Tramp Remote-Compile in Emacs 27.1

From: Duncan Greatwood <[email-masked]>
Date: Sun, 3 Jan 2021 11:27:17 -0800

Firstly, my apologies. The test.cpp I supplied was an attempt at a quick
simplification, and as you said it doesn't produce "enough" syntax errors
actually.

I am pasting below a test.cpp that I have verified on my setup does hang
the tramp window.

I'm afraid that there is another complication for reproducability. I cannot
get the issue to reproduce when I do "M-x compile" then invoking "gcc
test.cpp". It appears to reproduce only when doing "make" on a larger /
more complex project containing test.cpp. This is true even when test.cpp
is the first file that compiles in the project upon "make".

I attempted to make a small autotools project containing test.cpp, but even
that doesn't seem to reproduce the tramp hang. Only by including test.cpp
in a large preexisting project does the hang occur, at least for me.

I would suggest that you take a favorite large C++ autotools project, add
test.cpp to the source tree and Makefile.am, and see if the hang reproduces
for you.

For your reference, I am also pasting the output from the hung tramp window
when I added test.cpp to a library within one of my own larger projects.

Regards,
D.
======= Hung Tramp Window ==========

-*- mode: compilation; default-directory:
"/ssh:username@TWR1HM:/home/username/Dropbox/progs/thisprog/sbshared/src/"
-*-
Compilation started at Sun Jan  3 11:02:36

make -k
make  all-am
make[1]: Entering directory
'/home/username/Dropbox/progs/thisprog/sbshared/src'
/bin/bash ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.
 -std=c++11 -Wall -Werror -Wclobbered -Wempty-body -Wignored-qualifiers
-Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized
-Winit-self -Wcast-align -Wfloat-equal -Wformat=2 -Wno-psabi
 -I/usr/include/libxml2 -I../../../kilo  -I../../../rapidxml  -g3 -Og
-DDEBUG=1 -MT test.lo -MD -MP -MF .deps/test.Tpo -c -o test.lo test.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -std=c++11 -Wall -Werror
-Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers
-Wsign-compare -Wtype-limits -Wuninitialized -Winit-self -Wcast-align
-Wfloat-equal -Wformat=2 -Wno-psabi -I/usr/include/libxml2 -I../../../kilo
-I../../../rapidxml -g3 -Og -DDEBUG=1 -MT test.lo -MD -MP -MF
.deps/test.Tpo -c test.cpp  -fPIC -DPIC -o .libs/test.o

==================================
// test.cpp - for lots of syntax errors

#include <mutex>
#include <string>
#include <vector>
#include <memory>

class A1
{
    int f1();
    int f2();
    int f3();
    int f4();
    int f5();
    int f6();
    int f7();
    int f8();
    int f9();
};

class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
class Nested
{
    A1 m1;
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};

class A2
{
    std::shared_ptr<A1> a1ptr;
    A2() {A1 a1; a1ptr = &a1;}
};

#define AN_BODY                                                    \
    A1 x1;                                                         \
    A1 x2;                                                         \
    std::string s1(x1);                                            \
    std::string s2(x2);                                            \
Nested n1;                                                              \
const std::vector<std::string> v1(1, a1);                               \
const std::vector<std::string> v1(1, n1);                               \
std::vector<std::string> * v1_cptr(&v1);                                \
return(s1+s2);

int A1::f1()
{
    AN_BODY;
}

int A1::f2()
{
    AN_BODY;
}

int A1::f3()
{
    AN_BODY;
}

int A1::f4()
{
    AN_BODY;
}

int A1::f5()
{
    AN_BODY;
}

int A1::f6()
{
    AN_BODY;
}

int A1::f7()
{
    AN_BODY;
}

int A1::f8()
{
    AN_BODY;
}

int A1::f9()
{
    AN_BODY;
}

int A1::f10()
{
    AN_BODY;
}

int main(int argc, char* argv[])
{
    AN_BODY;
}
// end test.cpp

==================================
On Sun, Jan 3, 2021 at 2:27 AM Michael Albinus <[email-masked]>
wrote:

> Michael Albinus <[email-masked]> writes:
>
> Hi Duncan,
>
> >> Is there anything I can do that would help diagnose / pinpoint or
> >> whatever? Either with the ctrl-gx3 matter, or indeed with the
> >> underlying hang in the tramp compile window which requires the use of
> >> ctrl-gx3.
> >
> > I will try to reproduce it locally. Since I don't know where to start
> > with debugging, I cant give you instructions for this yet.
>
> I've tried to trigger this error, but I cannot. Calling "M-x compile",
> and invoking "gcc test.cpp" then, returns immediately with one error
> message:
>
> --8<---------------cut here---------------start------------->8---
> -*- mode: compilation; default-directory: "/ssh:detlef:/home/albinus/tmp/"
> -*-
> Compilation started at Sun Jan  3 11:23:16
>
> gcc test.cpp
> test.cpp:2:13: error: expected constructor, destructor, or type conversion
> before ‘(’ token
>     2 |   DummyClass(
>       |             ^
>
> Compilation exited abnormally with code 1 at Sun Jan  3 11:23:16
> --8<---------------cut here---------------end--------------->8---
>
> What does it need to hang Emacs/Tramp, compiling this file?
>
> >> Best regards,
> >> Duncan
>
> Best regards, Michael.