unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: segfault when using XIM with multi-tty on gnu/linux
@ 2008-12-13  5:55 Chong Yidong
  2008-12-13 11:03 ` Zsitvai János
  0 siblings, 1 reply; 9+ messages in thread
From: Chong Yidong @ 2008-12-13  5:55 UTC (permalink / raw)
  To: David Smith; +Cc: emacs-devel

> Is the call to XCloseIM() in xim_close_dpy (xterm.c:8316) necessary?
> Since if we HAVE_X11R6_XIM, xim_destroy_callback is called, and it
> claims there is no need to call XCloseIM (xterm.c:8143). A small patch
> is attached that changes the logic of xim_close_dpy slightly to call
> XCloseIM iff HAVE_XIM && !HAVE_X11R6_XIM. This fixes the segfault
> here.

I reverted your patch, as it was causing a memory leak.

> Steps to reproduce:
>  1. start emacs -nw
>  2. have XIM active for your X session (run scim -d)
>  3. start X11-capable emacs frame with emacsclient -c
>  4. close the X11 emacs frame
>  5. segfault with error 

I can't reproduce this bug, even now that Emacs calls XCloseIM.  Do you
still see the segfault?




^ permalink raw reply	[flat|nested] 9+ messages in thread
* segfault when using XIM with multi-tty on gnu/linux
@ 2008-08-13 16:37 David Smith
  0 siblings, 0 replies; 9+ messages in thread
From: David Smith @ 2008-08-13 16:37 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 2423 bytes --]

This is with git commit 36d10c7d (Aug 13, 2008).

Steps to reproduce:
 1. start emacs -nw
 2. have XIM active for your X session (run scim -d)
 3. start X11-capable emacs frame with emacsclient -c
 4. close the X11 emacs frame
 5. segfault with error

*** glibc detected *** /usr/bin/emacs: corrupted double-linked list: 0x083afdf0 ***
 
Backtrace:
#0  0xb78575c0 in _XSend () from /usr/lib/libX11.so.6
#1  0xb7857792 in _XFlush () from /usr/lib/libX11.so.6
#2  0xb7830a91 in XFlush () from /usr/lib/libX11.so.6
#3  0xb7882160 in ?? () from /usr/lib/libX11.so.6
#4  0xb78818d2 in _XimFlush () from /usr/lib/libX11.so.6
#5  0xb7872618 in ?? () from /usr/lib/libX11.so.6
#6  0xb785d134 in XCloseIM () from /usr/lib/libX11.so.6
#7  0x080d34ed in x_delete_display (dpyinfo=0x942dba0) at xterm.c:8315
#8  0x080d35ea in x_delete_terminal (terminal=0x942dd58) at xterm.c:10650
#9  0x080ca538 in Fdelete_terminal (terminal=155376988, force=137841993) at terminal.c:334
#10 0x08063e0f in Fdelete_frame (frame=155892172, force=137841993) at frame.c:1512
#11 0x08180d4d in Ffuncall (nargs=1, args=0xbf808ee0) at eval.c:3045
#12 0x0817de71 in Fcall_interactively (function=137877289, record_flag=137841945, keys=137880348) at callint.c:857
#13 0x08180d34 in Ffuncall (nargs=4, args=0xbf809090) at eval.c:3048
#14 0x08180e89 in call3 (fn=138006169, arg1=137877289, arg2=137841945, arg3=137841945) at eval.c:2872
#15 0x0812743e in command_loop_1 () at keyboard.c:1879
#16 0x0817f5d0 in internal_condition_case (bfun=0x81270e0 <command_loop_1>, handlers=137885153,
    hfun=0x8122060 <cmd_error>) at eval.c:1511
#17 0x08121473 in command_loop_2 () at keyboard.c:1338
#18 0x0817f6aa in internal_catch (tag=137881129, func=0x8121450 <command_loop_2>, arg=137841945) at eval.c:1247
#19 0x08121ec7 in command_loop () at keyboard.c:1317
#20 0x0812223b in recursive_edit_1 () at keyboard.c:942
#21 0x08122371 in Frecursive_edit () at keyboard.c:1004
#22 0x08116ffc in main (argc=2, argv=0xbf809744) at emacs.c:1689

Analysis:

 Is the call to XCloseIM() in xim_close_dpy (xterm.c:8316) necessary?
 Since if we HAVE_X11R6_XIM, xim_destroy_callback is called, and it
 claims there is no need to call XCloseIM (xterm.c:8143). A small patch
 is attached that changes the logic of xim_close_dpy slightly to call
 XCloseIM iff HAVE_XIM && !HAVE_X11R6_XIM. This fixes the segfault here.

Cheers,
- dds


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: prevent double free segfault when using XIM and multi-tty --]
[-- Type: text/x-diff, Size: 1015 bytes --]

From 2bf89dbf20821870c55040187593aa6e07dda844 Mon Sep 17 00:00:00 2001
From: David Smith <dds@google.com>
Date: Thu, 14 Aug 2008 01:21:27 +0900
Subject: [PATCH] Prevent double-free segfault when using XIM and multi-tty. When
 HAVE_X11R6_XIM is defined, let xim_destroy_callback, there is no need to
 call XCloseIM.

---
 src/xterm.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index a32f4e1..ed982b8 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8310,9 +8310,11 @@ xim_close_dpy (dpyinfo)
 	XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
 					  NULL, EMACS_CLASS,
 					  xim_instantiate_callback, NULL);
-#endif /* not HAVE_X11R6_XIM */
+#else /* not HAVE_X11R6_XIM */
+      /* if we have X11R6 xim, this causes a double-free */
       if (dpyinfo->display)
 	XCloseIM (dpyinfo->xim);
+#endif /* not HAVE_X11R6_XIM */
       dpyinfo->xim = NULL;
       XFree (dpyinfo->xim_styles);
     }
-- 
1.5.4.3


[-- Attachment #2: Type: application/pgp-signature, Size: 480 bytes --]

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-12-14  4:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-13  5:55 segfault when using XIM with multi-tty on gnu/linux Chong Yidong
2008-12-13 11:03 ` Zsitvai János
2008-12-13 14:46   ` Chong Yidong
2008-12-13 17:18     ` Zsitvai János
2008-12-13 17:31       ` Chong Yidong
2008-12-13 17:48         ` Zsitvai János
2008-12-13 22:11           ` Chong Yidong
2008-12-14  4:08             ` Zsitvai János
  -- strict thread matches above, loose matches on Subject: below --
2008-08-13 16:37 David Smith

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).