GNU bug report logs - #32794
27.0.50; emacsclient crashes on subsequent invocation when it cannot open a tty file

Previous Next

Package: emacs;

Reported by: John Shahid <jvshahid <at> gmail.com>

Date: Fri, 21 Sep 2018 15:04:01 UTC

Severity: normal

Tags: patch

Found in version 27.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


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

From: John Shahid <jvshahid <at> gmail.com>
To: 32794 <at> debbugs.gnu.org
Subject: Re: bug#32794: 27.0.50;
 emacsclient crashes on subsequent invocation when it cannot open a
 tty file
Date: Fri, 21 Sep 2018 11:30:54 -0400
[Message part 1 (text/plain, inline)]
Attached a patch that fixes the issue.

[0001-Cleanup-the-terminal-if-emacs_open-fails.-Bug-32794.patch (text/x-diff, inline)]
From 221bbe45fc7e98cdef5b95394be96bd73f667709 Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid <at> gmail.com>
Date: Fri, 21 Sep 2018 11:15:10 -0400
Subject: [PATCH] Cleanup the terminal if emacs_open fails. (Bug#32794)

* src/term.c (init_tty): Call delete_terminal_internal if emacs_open
  fail.

* src/terminal.c (delete_terminal): Move some code into
  delete_terminal_internal and call it.

* src/terminal.c (delete_terminal_internal):
* src/termhooks.h: Introduce 'delete_terminal_internal' to delete
  terminals that haven't been fully initialized.
---
 src/term.c      | 1 +
 src/termhooks.h | 1 +
 src/terminal.c  | 9 ++++++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/term.c b/src/term.c
index ce24f6915f..852dc23bd6 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4008,6 +4008,7 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
 	char const *diagnostic
 	  = (fd < 0) ? "Could not open file: %s" : "Not a tty device: %s";
 	emacs_close (fd);
+        delete_terminal_internal (terminal);
 	maybe_fatal (must_succeed, terminal, diagnostic, diagnostic, name);
       }
 
diff --git a/src/termhooks.h b/src/termhooks.h
index 211429169b..4e34105510 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -733,6 +733,7 @@ extern struct terminal *get_named_terminal (const char *);
 extern struct terminal *create_terminal (enum output_method,
 					 struct redisplay_interface *);
 extern void delete_terminal (struct terminal *);
+extern void delete_terminal_internal (struct terminal *);
 extern Lisp_Object terminal_glyph_code (struct terminal *, int);
 
 /* The initial terminal device, created by initial_term_init.  */
diff --git a/src/terminal.c b/src/terminal.c
index 18982fe704..e480359257 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -314,7 +314,6 @@ create_terminal (enum output_method type, struct redisplay_interface *rif)
 void
 delete_terminal (struct terminal *terminal)
 {
-  struct terminal **tp;
   Lisp_Object tail, frame;
 
   /* Protect against recursive calls.  delete_frame calls the
@@ -335,6 +334,14 @@ delete_terminal (struct terminal *terminal)
         }
     }
 
+  delete_terminal_internal (terminal);
+}
+
+void
+delete_terminal_internal (struct terminal *terminal)
+{
+  struct terminal **tp;
+
   for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal)
     if (! *tp)
       emacs_abort ();
-- 
2.18.0


This bug report was last modified 6 years and 295 days ago.

Previous Next


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