GNU bug report logs - #23939
Segfault in daemon mode Emacs when detaching an X session

Previous Next

Package: emacs;

Reported by: Doug Gilmore <dougjgilmore <at> gmail.com>

Date: Mon, 11 Jul 2016 06:08:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23939 in the body.
You can then email your comments to 23939 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23939; Package emacs. (Mon, 11 Jul 2016 06:08:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Doug Gilmore <dougjgilmore <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 11 Jul 2016 06:08:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Doug Gilmore <dougjgilmore <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Segfault in daemon mode Emacs when detaching an X session
Date: Sun, 10 Jul 2016 17:00:49 -0700
[Message part 1 (text/plain, inline)]
I have been running my own build of Emacs 24.2 for quite a while in
daemon mode for quite a while without any problems except that the
daemon would on rare occasions crash when I detached a windows frame
via the delete-frame Emacs command.  The other day this happened
several times in succession when connecting to a daemon running on
another host and I was able to catch the failure under an attached gdb
session.  I attached a backtrace and a prototype fix.

I have been building my own Emacs on Ubuntu-12/14 configured with the
--with-x-toolkit=lucid option, so this is not a Gtk issue.

Has anyone else been seeing this problem?

Thanks,

Doug
[emacs-gdb-log.txt (text/plain, attachment)]
[0001-Make-sure-x_error_message-is-not-NULL.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23939; Package emacs. (Sun, 05 May 2019 04:16:01 GMT) Full text and rfc822 format available.

Message #8 received at 23939 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Doug Gilmore <dougjgilmore <at> gmail.com>
Cc: 23939 <at> debbugs.gnu.org
Subject: Re: bug#23939: Segfault in daemon mode Emacs when detaching an X
 session
Date: Sun, 05 May 2019 00:15:40 -0400
#14958 = emacs --daemon crashing when X-frames are removed ungracefully
#11676 = Daemon crashes when ssh dies
#22174 = emacs --daemon crashes when ssh is disconnected. I am using lucid x toolkit.
merge 14958 11676 22174
#11639 = 24.0.95; Emacs daemon hangs when emacsclient was killed
# probably the GTK thing
merge 11639 8501
quit

Doug Gilmore <dougjgilmore <at> gmail.com> writes:

> I have been running my own build of Emacs 24.2 for quite a while in
> daemon mode for quite a while without any problems except that the
> daemon would on rare occasions crash when I detached a windows frame
> via the delete-frame Emacs command.  The other day this happened
> several times in succession when connecting to a daemon running on
> another host and I was able to catch the failure under an attached gdb
> session.  I attached a backtrace and a prototype fix.
>
> I have been building my own Emacs on Ubuntu-12/14 configured with the
> --with-x-toolkit=lucid option, so this is not a Gtk issue.
>
> Has anyone else been seeing this problem?

There are some other reports about Emacs daemon dying when closing X
sessions, but the backtraces look different, so I guess it's not the
same problem.

> #0  x_uncatch_errors () at /scratch/dgilmore/emacs-24.2/src/xterm.c:7672
> #1  0x00000000004cb588 in x_catch_errors_unwind (dummy=<optimized out>) at /scratch/dgilmore/emacs-24.2/src/xselect.c:546
> #2  0x000000000055b4ce in unbind_to (count=<optimized out>, value=11872738) at /scratch/dgilmore/emacs-24.2/src/eval.c:3433
> #3  0x000000000055b6e5 in unwind_to_catch (catch=0x7ffc44910f60, value=<optimized out>) at /scratch/dgilmore/emacs-24.2/src/eval.c:1314
> #4  0x000000000055d5a9 in Fsignal (error_symbol=11924850, data=38401462) at /scratch/dgilmore/emacs-24.2/src/eval.c:1764

> (gdb) p x_error_message
> $1 = (struct x_error_message_stack *) 0x0

> Subject: [PATCH] Make sure x_error_message is not NULL.
>
> Before dereferencing the pointer.

> @@ -7665,6 +7665,14 @@ x_uncatch_errors (void)
>  {
>    struct x_error_message_stack *tmp;
>  
> +  /* In rare situations when running Emacs run in daemon mode,
> +     shutting down an emacsclient via delete-frame can cause
> +     x_uncatch_errors to be called when x_error_message is set to
> +     NULL.  */
> +  
> +  if (x_error_message == NULL)
> +    return;
> +

If this really is possible, I guess a NULL check wouldn't be a bad
thing...





Added tag(s) patch. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 12 Aug 2020 02:05:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23939; Package emacs. (Wed, 19 Aug 2020 12:07:01 GMT) Full text and rfc822 format available.

Message #13 received at 23939 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Doug Gilmore <dougjgilmore <at> gmail.com>, 23939 <at> debbugs.gnu.org
Subject: Re: bug#23939: Segfault in daemon mode Emacs when detaching an X
 session
Date: Wed, 19 Aug 2020 14:06:29 +0200
Noam Postavsky <npostavs <at> gmail.com> writes:

>> +  /* In rare situations when running Emacs run in daemon mode,
>> +     shutting down an emacsclient via delete-frame can cause
>> +     x_uncatch_errors to be called when x_error_message is set to
>> +     NULL.  */
>> +  
>> +  if (x_error_message == NULL)
>> +    return;
>
> If this really is possible, I guess a NULL check wouldn't be a bad
> thing...

I've applied the patch to Emacs 28, as it seemed to fix the bug for
Doug, and it should probably not have any adverse affects otherwise.

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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 19 Aug 2020 12:07:01 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 23939 <at> debbugs.gnu.org and Doug Gilmore <dougjgilmore <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 19 Aug 2020 12:07:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 17 Sep 2020 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 326 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.