bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36648: emacs signals under gdb - [Re: connecting to a lost server pr


From: Eli Zaretskii
Subject: bug#36648: emacs signals under gdb - [Re: connecting to a lost server process
Date: Thu, 18 Jul 2019 08:35:04 +0300

> From: Madhu <address@hidden>
> Date: Sun, 14 Jul 2019 17:30:52 +0530
> 
> >> Earlier it used to be possible to gdb attach to the emacs process and
> >> to restart the server. Something like
> >> Feval(Fcar(Fread_from_string(build_string("(server-start)"),Qnil,Qnil)),Qnil)
> >> But for some time now that route hits a
> >> terminate_due_to_signal. (Apparently make-network-process tries to
> >> signal an error which calls emacs_abort which ends the show)
> >
> > Please report a bug with the details of that crash, it may or may not
> > be a bug.
> 
> I noticed a couple of different failure modes but this problem seems to
> be related to pselect.  I'm appending one backtrace. Note within the
> transcript emacs is started with
> 
> args:  -Q --eval '(progn (load-library "custom") (load-library "server") 
> (setq server-name "emacs-test"))'
> 
> After emacs is started by gdb I send it a TSTP to make it enter the
> debugger.

The data you collected shows that your attempt to restart the server
signals an error:

> #1  0x0000000000416a50 in emacs_abort ()
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/sysdep.c:2437
> #2  0x0000000000418a90 in signal_or_quit (error_symbol=XIL(0x58e0), 
>     data=XIL(0xdd5663), keyboard_quit=<optimized out>)
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/eval.c:1595
> #3  0x0000000000418aa9 in Fsignal (error_symbol=<optimized out>, 
>     data=data@entry=XIL(0xdd5663))
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/eval.c:1565
> #4  0x0000000000417118 in xsignal (data=XIL(0xdd5663), 
>     error_symbol=<optimized out>)
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/lisp.h:4101
> #5  report_file_errno (string=<optimized out>, name=name@entry=XIL(0xdd55f3), 
>     errorno=<optimized out>)
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/fileio.c:222
> #6  0x000000000041a663 in connect_network_socket (proc=XIL(0xd7f415), 
>     addrinfos=<optimized out>, use_external_socket_p=<optimized out>)
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/process.c:3633
> #7  0x00000000005a2cc6 in Fmake_network_process (nargs=<optimized out>, 
>     args=<optimized out>)
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/process.c:4246

See the call to report_file_errno in frame #5?  Signaling an error
while waiting for input is fatal in Emacs, so it aborts.

> Lisp Backtrace:
> "make-network-process" (0xffffc2a0)
> "server-running-p" (0xffffc690)
> "server-start" (0xffffcbc0)
> 
> (gdb) up 5
> #5  report_file_errno (string=<optimized out>, name=name@entry=XIL(0xdd55f3), 
>     errorno=<optimized out>)
>     at 
> /var/tmp/portage/app-editors/emacs-27.0.50-r3/work/emacs-27.0.50/src/fileio.c:222
> 222     xsignal (Fcar (data), Fcdr (data));
> 
> (gdb) pp data
> (file-missing "make client process failed" "No such file or directory" :name 
> "server-client-test" :family local :server nil :noquery t :service 
> "/dev/shm/madhu/emacs/emacs-test")

So here's the reason for the problem: the way you try to restart the
server fails because the socket no longer exists.

> Additional notes:
> - make-network-process signals a (file-missing "make client process failed" 
> "No such file or directory" :name "server-client-test" :family local :server 
> nil :noquery t :service "/dev/shm/madhu/emacs/emacs-test")
>   which is not supposed to happen since the file would be created by the
>   system call to socket.  I suspect a wrong error is being reported
>   because of some problem with pselect (which is interrupted when we
>   enter gdb)

I don't think the error is wrong.  Look at the function
server-running-p: it attempts to determine whether the server is
already running by creating a client process of the server.  This
happens _before_ restarting the server.  IOW, Emacs attempts to clean
up if the server is already running.  In your case, the socket
doesn't exist, so this method of restarting the server can no longer
be used safely, because when you attach GDB to Emacs, Emacs will
almost always be waiting for input, where every error is fatal.

Instead, I suggest to restart the server by binding a function to the
sigusr1 or sigusr2 event.  These events can be triggered by the
corresponding signals.

> - another unrelated emacs-bug. M-x gud-gdb -- emacs .. with the above
>   arg line fails to pass the quoted arguments to gdb.

Sorry, I don't think I understand what exactly do you mean by "with
the above arg line".  Can you please show a full sequence of commands
that produce this problem?

Thanks.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]