GNOME Bugzilla – Bug 483223
im-xim.so leaves callbacks connected to display "closed" signal when module is unloaded -> SIGSEGV
Last modified: 2007-10-07 18:19:41 UTC
Steps to reproduce: 1. export GTK_IM_MODULE=xim 2. gtk_im_context_set_client_window(im_context, window); 3. g_object_unref( (G_OBJECT (im_context)); 4. gdk_display_close(display); Stack trace:
+ Trace 167601
Other information:
Created attachment 96608 [details] test program
Created attachment 96663 [details] [review] xim-display-close.patch Does this patch make things work for you ?
(In reply to comment #2) > Does this patch make things work for you ? Unfortunately this doesn't help as neither xim_destroy_callback nor XCloseIM are called. I'll attach a modified version that does work for me.
Created attachment 96681 [details] [review] run and disconnect display closed signal handlers, and remove problem XFree This cleans up the open_ims in gtk_im_context_xim_shutdown, disconnecting the display "closed" signal handlers. It retains the changes in the previous patch to move the signal connect from xim_info_try_im to setup_im (where it should be), but removes the changes to remove the handler in xim_destroy_callback, as the GtkXIMInfo should still be removed from open_ims. The other issue is that the XFree (info->xim_styles->supported_styles) fails because support_styles is not Xmalloced but the memory is included in the same malloc as the XIMStyles. Search for XIMStyles here: http://cgit.freedesktop.org/xorg/lib/libX11/tree/modules/im/ximcp/imRmAttr.c This is actually in contrast to http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/xlibi18n/XDefaultIMIF.c I'm not sure when the later is used, but the former seems more consistent with the literal wording of the XGetIMValues man page: If T itself is a pointer type, then XGetIMValues allocates memory to store the actual data, and the client is responsible for freeing this data by calling XFree with the returned pointer. (The extra XFree in gtkimcontextxim.c was added in this revision http://svn.gnome.org/viewcvs/gtk%2B/trunk/modules/input/gtkimcontextxim.c?r1=7084&r2=7097 but looking at Bug 87482, which landed soon after, it seems xim_info_display_closed hasn't had much testing.) This patch removes the extra XFree, which is consistent with the single XFree of XIMValuesList *ic_values.
Thanks, looks good to me. Feel free to commit; else I will get to it before the next release.
Created attachment 96728 [details] [review] add some checks to xim_info_display_closed It occurred to me that as xim_info_display_closed may now be called with a GtkXIMInfo that hasn't gone through setup_im, we should do some checks on what needs disconnecting or XFreeing.
That makes a lot of sense, thanks
Thanks for review/accept. We still need the the patch in attachment 96681 [details] [review] though as attachment 96728 [details] [review] was incremental. (I can't remove the obsolete.) I don't have commit access so I'll leave committing the two patches to you (or anyone else who wishes).
2007-10-07 Matthias Clasen <mclasen@redhat.com> * modules/input/gtkimcontextxim.c: Clean up issues around with life cycle handling. (#483223, Karl Tomlinson)