segmentation fault triggered in QKeyMapper::changeKeyboard()

  • From time to time, we get a segfault with a stacktrace similar to the one at the end of this message.
    All stacktraces seem to originate in QKeyMapper::changeKeyboard().
    The lower stack frames and the actual widget (QLineEdit in the example) differ between crashes.

    We are using PyQt (Qt4.8.2 and sip 4.13.3).
    We noted that, from Qt5.0.0 onwards, a large part of this QKeyMapper::changeKeyboard() function was commented out: an extra #if 0 was added as can be seen in the code snippet below

    void QKeyMapper::changeKeyboard()
        // ## TODO: Support KeyboardLayoutChange on QPA
    #if 0
        // inform all toplevel widgets of the change
        QEvent e(QEvent::KeyboardLayoutChange);
        QWidgetList list = QApplication::topLevelWidgets();
        for (int i = 0; i < list.size(); ++i) {
    	        QWidget *w =;
    	        qt_sendSpontaneousEvent(w, &e);

    Any ideas

    • why this extra #if 0 was added in Qt5
    • whether it is safe to also add this in (a local build of) Qt4.8
    • what this code was supposed to do in the first place?

    Thanks in advance,

    PS: Below is an example of the stacktraces we get

    #0  0x00007fe60a5d8f6b in raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:42
    #1  <signal handler called>
    #2  sip_api_is_py_method (gil=0x7fff73c87d1c, pymc=0xfff3d8e "", sipSelf=0xfd54200, cname=0x0, mname=0x7fe5f1222ce4 "changeEvent")
        at /build/buildd-sip4_4.13.3-2-amd64-4XEr_m/sip4-4.13.3/siplib/siplib.c:7573
    #3  0x00007fe5f10300a9 in sipQLineEdit::changeEvent (this=0xfff3d50, a0=0x7fff73c88490) at sipQtGuipart5.cpp:43517
    #4  0x00007fe5f02211dc in QWidget::event (this=0xfff3d50, event=0x7fff73c88490) at kernel/qwidget.cpp:8752
    #5  0x00007fe5f05d9ac7 in QLineEdit::event (this=0xfff3d50, e=0x7fff73c88490) at widgets/qlineedit.cpp:1524
    #6  0x00007fe5f107466b in event (a0=0x7fff73c88490, this=0xfff3d50) at sipQtGuipart5.cpp:43589
    #7  sipQLineEdit::event (this=0xfff3d50, a0=0x7fff73c88490) at sipQtGuipart5.cpp:43581
    #8  0x00007fe5f01d170c in QApplicationPrivate::notify_helper (this=this@entry=0x7ddafe0, receiver=receiver@entry=0xfff3d50, e=e@entry=0x7fff73c88490) at kernel/qapplication.cpp:4556
    #9  0x00007fe5f01d5b8a in QApplication::notify (this=0x7ffedb0, receiver=0xfff3d50, e=0x7fff73c88490) at kernel/qapplication.cpp:4417
    #10 0x00007fe5f11fdc66 in notify (a1=0x7fff73c88490, a0=0xfff3d50, this=0x7ffedb0) at sipQtGuipart9.cpp:35916
    #11 sipQApplication::notify (this=0x7ffedb0, a0=0xfff3d50, a1=0x7fff73c88490) at sipQtGuipart9.cpp:35908
    #12 0x00007fe608dc5b5e in QCoreApplication::notifyInternal (this=0x7ffedb0, receiver=0xfff3d50, event=0x7fff73c88490) at kernel/qcoreapplication.cpp:915
    #13 0x00007fe5f02271c4 in QKeyMapper::changeKeyboard () at kernel/qkeymapper.cpp:99
    #14 0x00007fe5f024c3cd in QApplication::x11ProcessEvent (this=0x7ffedb0, event=0x7fff73c88a00) at kernel/qapplication_x11.cpp:3365

  • can you show the content of sipQLineEdit::changeEvent?

  • In the PyQt 4.9.4 code downoaded from I find
    (Note that we are using 4.9.3 but I couldn't find the sources of that version)

    void sipQLineEdit::changeEvent(QEvent *a0)
        sip_gilstate_t sipGILState;
        PyObject *sipMeth;
        sipMeth = sipIsPyMethod(&sipGILState,&sipPyMethods[14],sipPySelf,NULL,sipName_changeEvent);
        if (!sipMeth)
        typedef void (*sipVH_QtCore_17)(sip_gilstate_t,PyObject *,QEvent *);

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.