GNOME Bugzilla – Bug 309054
Need unregister xim_instantiate_callback at finalize of xim input module
Last modified: 2005-06-30 05:01:34 UTC
Please describe the problem: gtk+ applications crash with following procedure. See also https://bugs.freedesktop.org/show_bug.cgi?id=3630 (bug report on uim). I tested this with gtk+2-2.6.7. 1. Run gtk+ application with GTK_IM_MODULE=xim XMODIFIERS=@im=kinput2 without running process of kinput2. 2. Then change the input context of gtk+ to any other method from xim. 3. Run kinput2 process from a terminal. 4. Application crashes. It seems that unregister xim_instantiate_callback is needed at finalization if context_xim->im_info->reconnecting == TRUE. Please apply the attached patch to gtkimcontextxim.c. Cheers, -- Etsushi Kato ekato@ees.hokudai.ac.jp Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Created attachment 48352 [details] [review] Fix at the finalization of the xim context
In addition, I found another bug in relation to XNDestroyCallback. 1. Run application with GTK_IM_MODULE=xim XMODIFIERS=kinput2 with kinput2 running. 2. Change application's gtk im context to other im from xim. 3. kill kinput2. 4. Application crashes. In this case xim_destroy_callback is called and causes the crash. So it is needed to remove this callback at finalizing xim context. Again, I created unified patch to fix the problem in addition to former problem. Please apply. Cheers,
Created attachment 48356 [details] [review] Revised patch
I just unconditionally unregistered the callbacks. 2005-06-26 Matthias Clasen <mclasen@redhat.com> * modules/input/gtkimcontextxim.c (gtk_im_context_xim_finalize): Unregister XIM callbacks here. (#309054)
Thanks for your quick reply. But removing the condition causes crash if kinput2 is not running. 1. run gedit (GTK_IM_MODULE=xim XMODIFIERS=@im=kinput2) without kinput2 process. 2. change im context to default. 3. gedit crashes. This is because XSetIMValues() is called without successful XOpenIM(). So context_xim->im_info->reconnecting == TRUE check is definitely needed. Cheers, -- Etsushi Kato ekato@ees.hokudai.ac.jp
Should be fixed now. Can you retest ?
Tested with revision 1.49.2.3 and confirmed works fine. Thanks!
Hi again, I've noticed that my patch just consider a application with only one input context (like leafpad). This introduced a side effect in removing destoy_callback in a application with many input context. For applications with more that one input context, removing destroy callback while finalizing a selected context causes problem since there still exists other x input context in the application. For these applications, destroy callback is needed to be called in the remained contexts when XIM server (kinput2) is killed. Here is the patch that the callbacks will be removed only if ics->next is NULL (only one input context exists and the context is finalized). --- gtkimcontextxim.c.orig Tue Jun 28 17:04:05 2005 +++ gtkimcontextxim.c Thu Jun 30 11:25:30 2005 @@ -565,7 +565,7 @@ context_xim->finalizing = TRUE; - if (context_xim->im_info) + if (context_xim->im_info && !context_xim->im_info->ics->next) { GdkDisplay *display;