Tk Source Code

View Ticket
Login
Ticket UUID: 7d967c68a09e07e355358af40f36dd5dd84c7022
Title: Tk applications segmentation fault when ibus-daemon IME is restarted
Type: Bug Version: 8.6
Submitter: anonymous Created on: 2016-09-23 18:02:56
Subsystem: 69. Events Assigned To: jan.nijtmans
Priority: 7 High Severity: Important
Status: Closed Last Modified: 2017-02-10 11:40:24
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2017-02-10 11:40:24
Description:
Tk does not play happily in conjunction with the ibus-daemon IME.
There are various issues, but the segmentation faults should be easier to find.
And perhaps fixing those will lead to a general fix.

Reference: http://stackoverflow.com/questions/39547796/tcl-tk-key-event-queue-overflow-bug

One method to get a segmentation fault:

bll-tecra:bll$ wish
% # restart ibus-daemon
% ttk::entry .g
.g
% pack .g
% Segmentation fault
bll-tecra:bll$ 

Another method to get a segmentation fault:

bll-tecra:bll$ wish
% ttk::entry .g
.g
% bind . <Key> "puts %K"
% pack .g
% # restart ibus-daemon
% Segmentation fault
User Comments: jan.nijtmans added on 2017-02-10 11:40:24:
Fix applied to core-8-6-branch and trunk. Thanks!

bll added on 2017-02-07 01:08:50:
Retested using core-8-6-branch.

The instantiation registration and destroy callbacks are correct.  Everything is working good except the xim generation tracking is not quite right.

Patch will be attached, fixes for xim generation tracking.

Other IMEs (xim, scim, fcitx, etc.) are untested.

jan.nijtmans added on 2017-02-05 19:35:03:
Patch committed to core-8-6-branch and trunk. Thanks, Brad, for being so persistent: I think indeed that this deserves attention. Unfortunately not many people know enough about X11 to do that. (me neither, actually)

jan.nijtmans added on 2016-12-15 16:07:53:
Patch committed to branch "bug-7d967c68", for easier testing and evaluation. Thanks!

bll added on 2016-12-13 23:30:16:
Tests for 8.6.6 and IM patched version are identical.

bll added on 2016-12-13 22:53:03:
Please review.
If you have a better idea on how to invalidate the XIC in the multitude of TkWindow's, please let me know.

bll added on 2016-12-13 22:44:06:
Patch (vs. 8.6.6) attached to fix the IME interaction problems.  I still need to run the tests and compare to make sure nothing broke.

Is there an 'indent' configuration file available to apply the standard Tcl/Tk C style?

bll added on 2016-12-12 02:32:13:
Trace #1: IME restarted immediately after wish started

#0  0x00000000006aab10 in ?? ()
#1  0x00007ffff6ae6885 in XCreateIC (im=0x6a9980)
    at ../../../src/xlibi18n/ICWrap.c:247
#2  0x00007ffff7a714c3 in CreateXIC (winPtr=0x703aa0)
    at /home/bll/tcl/tk8.6.6/unix/../generic/tkEvent.c:346
#3  0x00007ffff7a72417 in Tk_HandleEvent (eventPtr=0x7fffffffd910)
    at /home/bll/tcl/tk8.6.6/unix/../generic/tkEvent.c:1306
#4  0x00007ffff7a9e8f5 in TkDoConfigureNotify (winPtr=0x6aaaa0)
    at /home/bll/tcl/tk8.6.6/unix/../generic/tkWindow.c:2200

...

Crashing at (in CreateXIC):

    winPtr->inputContext = XCreateIC(dispPtr->inputMethod,
            XNInputStyle, dispPtr->inputStyle,
            XNClientWindow, winPtr->window,
            XNFocusWindow, winPtr->window,
            preedit_attname, preedit_attlist,
            NULL);

(gdb) p *dispPtr->inputMethod
$4 = {methods = 0x0, ...

dispPtr->inputMethod->methods is null after the restart of the ibus daemon.


It appears that with X11R6, these functions should be used to reinitialize the IM when the callbacks become available and unavailable.

XRegisterIMINstantiateCallback	     Registers a callback function called when an input method becomes available
XUnregisterIMInstantiateCallback     Registers a callback function called when an input method becomes unavailable

c.f. http://www.digiater.nl/openvms/freeware/v50/vim/src/src-v56/multbyte.c

Attachments: