From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#36648: emacs signals under gdb - [Re: connecting to a lost server process Date: Thu, 18 Jul 2019 08:35:04 +0300 Message-ID: <8336j3zz07.fsf@gnu.org> References: <20190712062057.15599.qmail@localhost.localdomain> <83r26v3cy3.fsf@gnu.org> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="27055"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36648@debbugs.gnu.org To: Madhu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 18 07:36:09 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hnz5M-0006v5-TU for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Jul 2019 07:36:09 +0200 Original-Received: from localhost ([::1]:34318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnz5L-0007we-So for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Jul 2019 01:36:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34986) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnz5I-0007wI-4r for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 01:36:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnz5G-0002M0-UK for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 01:36:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnz5G-0002Lr-QT for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 01:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hnz5G-0005Vi-IA for bug-gnu-emacs@gnu.org; Thu, 18 Jul 2019 01:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Jul 2019 05:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36648 X-GNU-PR-Package: emacs Original-Received: via spool by 36648-submit@debbugs.gnu.org id=B36648.156342812121132 (code B ref 36648); Thu, 18 Jul 2019 05:36:02 +0000 Original-Received: (at 36648) by debbugs.gnu.org; 18 Jul 2019 05:35:21 +0000 Original-Received: from localhost ([127.0.0.1]:53276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hnz4a-0005Ul-Qw for submit@debbugs.gnu.org; Thu, 18 Jul 2019 01:35:21 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hnz4Z-0005UZ-2w for 36648@debbugs.gnu.org; Thu, 18 Jul 2019 01:35:19 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hnz4T-0001kB-KY; Thu, 18 Jul 2019 01:35:13 -0400 Original-Received: from [176.228.60.248] (port=1889 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hnz4S-0003Gk-OA; Thu, 18 Jul 2019 01:35:13 -0400 In-reply-to: (message from Madhu on Sun, 14 Jul 2019 17:30:52 +0530) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:163281 Archived-At: > From: Madhu > 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=) > 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=, > 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=) > 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=, name=name@entry=XIL(0xdd55f3), > errorno=) > 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=, use_external_socket_p=) > 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=, > args=) > 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=, name=name@entry=XIL(0xdd55f3), > errorno=) > 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.