From xemacs-m  Fri Mar 21 15:09:33 1997
Received: from mailbox1.ucsd.edu (mailbox1.ucsd.edu [132.239.1.53])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id PAA06966
	for <xemacs-beta@xemacs.org>; Fri, 21 Mar 1997 15:09:32 -0600 (CST)
Received: from sdnp5.ucsd.edu (sdnp5.ucsd.edu [132.239.79.10]) by mailbox1.ucsd.edu (8.8.5/8.6.9) with SMTP id NAA03276 for <xemacs-beta@xemacs.org>; Fri, 21 Mar 1997 13:09:31 -0800 (PST)
Received: by sdnp5.ucsd.edu (SMI-8.6/SMI-SVR4)
	id NAA24829; Fri, 21 Mar 1997 13:08:08 -0800
Sender: dmoore@sdnp5.ucsd.edu
To: xemacs-beta@xemacs.org
Subject: Re: Two crashes!
References: <xcdendg261k.fsf@rodman.cs.uchicago.edu>
X-Face: "oX;zS#-JU$-,WKSzG.1gGE]x^cIg!hW.dq>.f6pzS^A+(k!T|M:}5{_%>Io<>L&{hO7W4cicOQ|>/lZ1G(m%7iaCf,6Qgk0%%Bz7b2-W3jd0m_UG\Y;?]}4s0O-U)uox>P3JN)9cm]O\@,vy2e{`3pb!"pqmRy3peB90*2L
Mail-Copies-To: never
Mime-Version: 1.0 (generated by tm-edit 7.105)
Content-Type: multipart/mixed;
 boundary="Multipart_Fri_Mar_21_13:08:07_1997-1"
Content-Transfer-Encoding: 7bit
From: David Moore <dmoore@ucsd.edu>
Date: 21 Mar 1997 13:08:07 -0800
In-Reply-To: Soren Dayton's message of 15 Mar 1997 15:34:31 -0600
Message-ID: <rvg1xpuf60.fsf@sdnp5.ucsd.edu>
Lines: 111
X-Mailer: Gnus v5.4.28/XEmacs 19.15(beta100)

--Multipart_Fri_Mar_21_13:08:07_1997-1
Content-Type: text/plain; charset=US-ASCII

Soren Dayton <csdayton@cs.uchicago.edu> writes:

> I started up XEmacs.  The authentication failed.  This is the lisp
> backtrace and C backtrace.  All of my attempts at xauth authentication
> failed to I had to restart my Xserver.


> =>[4] assert_failed(file = 0x45d2cc "device-x.c", line = 116, expr = 0x45d2d8 "abort()"), line 2193 in "emacs.c"
>   [5] get_device_from_display(dpy = 0x5cb000), line 116 in "device-x.c"
>   [6] x_IO_error_handler(disp = 0x5cb000), line 603 in "device-x.c"
>   [7] _XIOError(0x5cb000, 0x104126d0, 0x0, 0x0, 0x0, 0x479990), at 0xef340300
>   [8] _XRead(0x5cb000, 0xefffdcbc, 0x8, 0x5cb008, 0x20, 0x0), at 0xef32d274
>   [9] XOpenDisplay(0x0, 0x473848, 0xef346f18, 0xef346f20, 0x5cb4c0, 0x5cb2c0), at 0xef33ba24
>   [10] XtOpenDisplay(0x539000, 0x4c3b20, 0x0, 0xefffdde0, 0x4434f8, 0xe), at 0xef3d3854
>   [11] x_init_device(d = 0x532400, props = 273297412), line 241 in "device-x.c"

The code really doesn't handle this kind of a failure well.  Here's a
patch against 19.15b100 which might make it handle this a bit more
cleanly, although I can't really test it. :) It may also show the way to
getting rid of some more abort()s due to get_device_from_display, by
allowing incremental updates to callers to that function.


--Multipart_Fri_Mar_21_13:08:07_1997-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="device-x.c.diff"
Content-Transfer-Encoding: 7bit

--- device-x.c.orig	Fri Mar 21 13:05:47 1997
+++ device-x.c	Fri Mar 21 13:06:27 1997
@@ -99,8 +99,8 @@
 /*                          helper functions                            */
 /************************************************************************/
 
-struct device *
-get_device_from_display (Display *dpy)
+static struct device *
+get_device_from_display_1 (Display *dpy)
 {
   Lisp_Object devcons, concons;
 
@@ -111,11 +111,25 @@
 	return d;
     }
 
-  /* Only devices we are actually managing should ever be used as an
-     argument to this function. */
-  abort ();
+  return 0;
+}
+
+struct device *
+get_device_from_display (Display *dpy)
+{
+  Display *d = get_device_from_display_1 (dpy);
+
+  if (!d) {
+    /* This isn't one of our displays.  Let's crash? */
+    stderr_out
+      ("\n%s: Fatal X Condition.  Asked about display we don't own: \"%s\"\n",
+       (STRINGP (Vinvocation_name) ?
+	(char *) XSTRING_DATA (Vinvocation_name) : "xemacs"),
+       DisplayString (dpy) ? DisplayString (dpy) : "???");
+    abort();
+  }
 
-  return 0; /* suppress compiler warning */
+  return d;
 }
 
 struct device *
@@ -578,8 +592,12 @@
 {
   /* This function can GC */
   Lisp_Object dev;
-  struct device *d = get_device_from_display (disp);
-  XSETDEVICE (dev, d);
+  struct device *d = get_device_from_display_1 (disp);
+
+  if (d)
+    XSETDEVICE (dev, d);
+  else
+    dev = Qnil;
 
   if (NILP (find_nonminibuffer_frame_not_on_device (dev)))
     {
@@ -607,7 +625,8 @@
          QLength (disp));
     }
 
-  enqueue_magic_eval_event (io_error_delete_device, dev);
+  if (d)
+    enqueue_magic_eval_event (io_error_delete_device, dev);
 
   return 0;
 }


--Multipart_Fri_Mar_21_13:08:07_1997-1
Content-Type: text/plain; charset=US-ASCII

-- 
David Moore <dmoore@ucsd.edu>       | Computer Systems Lab      __o
UCSD Dept. Computer Science - 0114  | Work: (619) 534-8604    _ \<,_
La Jolla, CA 92093-0114             | Fax:  (619) 534-1445   (_)/ (_)
<URL:http://oj.egbt.org/dmoore/>    | In a cloud bones of steel.

--Multipart_Fri_Mar_21_13:08:07_1997-1--

