After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 483223 - im-xim.so leaves callbacks connected to display "closed" signal when module is unloaded -> SIGSEGV
im-xim.so leaves callbacks connected to display "closed" signal when module i...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Input Methods
2.12.x
Other All
: Normal critical
: ---
Assigned To: Hidetoshi Tajima
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-10-04 05:13 UTC by Karl Tomlinson
Modified: 2007-10-07 18:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (1.03 KB, text/plain)
2007-10-04 05:14 UTC, Karl Tomlinson
  Details
xim-display-close.patch (2.07 KB, patch)
2007-10-04 20:23 UTC, Matthias Clasen
none Details | Review
run and disconnect display closed signal handlers, and remove problem XFree (3.95 KB, patch)
2007-10-05 08:11 UTC, Karl Tomlinson
committed Details | Review
add some checks to xim_info_display_closed (2.03 KB, patch)
2007-10-05 20:55 UTC, Karl Tomlinson
committed Details | Review

Description Karl Tomlinson 2007-10-04 05:13:37 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:
  • #0 ??
  • #1 IA__g_cclosure_marshal_VOID__BOOLEAN
    at gmarshal.c line 111
  • #2 IA__g_closure_invoke
    at gclosure.c line 490
  • #3 signal_emit_unlocked_R
    at gsignal.c line 2440
  • #4 IA__g_signal_emit_valist
    at gsignal.c line 2199
  • #5 IA__g_signal_emit
    at gsignal.c line 2243
  • #6 IA__gdk_display_close
    at gdkdisplay.c line 185
  • #7 main
    at gtkim.c line 53


Other information:
Comment 1 Karl Tomlinson 2007-10-04 05:14:34 UTC
Created attachment 96608 [details]
test program
Comment 2 Matthias Clasen 2007-10-04 20:23:54 UTC
Created attachment 96663 [details] [review]
xim-display-close.patch

Does this patch make things work for you ?
Comment 3 Karl Tomlinson 2007-10-05 08:08:17 UTC
(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.

Comment 4 Karl Tomlinson 2007-10-05 08:11:25 UTC
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.
Comment 5 Matthias Clasen 2007-10-05 12:52:33 UTC
Thanks, looks good to me.
Feel free to commit; else I will get to it before the next release.
Comment 6 Karl Tomlinson 2007-10-05 20:55:29 UTC
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.
Comment 7 Matthias Clasen 2007-10-05 21:14:10 UTC
That makes a lot of sense, thanks
Comment 8 Karl Tomlinson 2007-10-05 21:30:01 UTC
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).
Comment 9 Matthias Clasen 2007-10-07 18:19:41 UTC
2007-10-07  Matthias Clasen  <mclasen@redhat.com>

        * modules/input/gtkimcontextxim.c: Clean up issues around
        with life cycle handling.  (#483223, Karl Tomlinson)