Skip to content

Segmentation fault / double free in Jetbrains IDE crashes entire Gnome DE #2889

Closed

Description

@cthbleachbit

Distribution and Version

Archlinux

Desktop Environment and Version

GNOME 49

Session Type

Wayland

Application and Version

RustRover 2025.3.5, CLion 2026.1, ibus-rime 1.6.0-1, ibus-anthy 1.5.18-1

IBus version

1.5.33

Issue Description

Typing under RIME or anthy in Jetbrains IDE seems to cause a double free inside GNOME desktop shell process. Double free seems to only occur with a IME active. In other words not producible with default "en" layout active.
So far I could only reproduce this double free on Jetbrains IDE but not other applications.

On a system with global memory poisoning, this will crash the gnome-shell process with segmentation fault, and boot user back to the login screen losing any unsaved work.

The issue is reproducible on both Archlinux and AOSC OS on gnome 49, with or without any shell extensions active. On archlinux the crash causes gnome-shell to complain about memory management issue in stderr. On AOSC OS the invalid pointer poisoned to 0xAAAAAAAA will crash the shell.

Steps to Reproduce

1. Configure ibus with anthy or rime.
2. Start Clion and open some random project.
3. Open IDE built-in terminal.
4. Activate RIME or anthy and begin typing in the code editor.
5. Either press ESC or commit the chosen word candidate.
6. Click back and forth between the code editor and the terminal pane.

Without memory hardening, observe double free in the gnome-shell stdout/stderr in the following order:

3月 26 18:24:46 test-vm gnome-shell[1603]: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
3月 26 18:24:46 test-vm gnome-shell[1603]: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
3月 26 18:24:46 test-vm gnome-shell[1603]: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
3月 26 18:24:46 test-vm gnome-shell[1603]: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
3月 26 18:24:46 test-vm gnome-shell[1603]: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
3月 26 18:24:46 test-vm gnome-shell[1603]: Object 0x563c0092d170 of type IBusAttrList has been finalized while it was still owned by gjs, this is due to invalid memory management.


With memory poisoning freed area to a 0xAAAA pattern this will crash gnome-shell. Enable poisoning with GLIBC tunable environment variable `MALLOC_PERTURB_=1` system wide.

When observing the entire shell process under valgrind:

==4438== 
==4438== Invalid read of size 8
==4438==    at 0x4D56149: g_type_check_instance_is_fundamentally_a (gtype.c:3915)
==4438==    by 0x4D3DD1F: g_object_unref (gobject.c:4743)
==4438==    by 0x30F8845E: ibus_text_destroy (ibustext.c:68)
==4438==    by 0x4D2D97B: g_closure_invoke (gclosure.c:916)
==4438==    by 0x4D4CCF2: signal_emit_unlocked_R.isra.0 (gsignal.c:3943)
==4438==    by 0x4D4E84E: signal_emit_valist_unlocked (gsignal.c:3535)
==4438==    by 0x4D4EAC8: g_signal_emit_valist (gsignal.c:3278)
==4438==    by 0x4D4EB83: g_signal_emit (gsignal.c:3598)
==4438==    by 0x30F88AAB: ibus_object_dispose (ibusobject.c:133)
==4438==    by 0x4D3DDB5: g_object_unref (gobject.c:4833)
==4438==    by 0x4F96286: UnknownInlinedFun (auto.h:207)
==4438==    by 0x4F96286: UnknownInlinedFun (auto.h:156)
==4438==    by 0x4F96286: UnknownInlinedFun (auto.h:255)
==4438==    by 0x4F96286: ObjectInstance::release_native_object() (object.cpp:2439)
==4438==    by 0x4F9A1BD: ObjectInstance::disassociate_js_gobject() (object.cpp:2662)
==4438==  Address 0x38660e00 is 48 bytes inside a block of size 112 free'd
==4438==    at 0x4850B4D: free_sized (vg_replace_malloc.c:1033)
==4438==    by 0x4D539E3: g_type_free_instance (gtype.c:1972)
==4438==    by 0x4D3DE48: g_object_unref (gobject.c:4920)
==4438==    by 0x4F96286: UnknownInlinedFun (auto.h:207)
==4438==    by 0x4F96286: UnknownInlinedFun (auto.h:156)
==4438==    by 0x4F96286: UnknownInlinedFun (auto.h:255)
==4438==    by 0x4F96286: ObjectInstance::release_native_object() (object.cpp:2439)
==4438==    by 0x4F9A1BD: ObjectInstance::disassociate_js_gobject() (object.cpp:2662)
==4438==    by 0x4F99239: UnknownInlinedFun (std_function.h:593)
==4438==    by 0x4F99239: ObjectInstance::remove_wrapped_gobjects_if(std::function<bool (ObjectInstance*)> const&, std::function<void (ObjectInstance*)> const&) [clone .constprop.0] (object.cpp:2187)
==4438==    by 0x4F99338: ObjectInstance::update_heap_wrapper_weak_pointers(JSTracer*, JS::Compartment*, void*) (object.cpp:2513)
==4438==    by 0x7D73857: UnknownInlinedFun (js/src/gc/GC.cpp:1733)
==4438==    by 0x7D73857: UnknownInlinedFun (js/src/gc/Sweeping.cpp:1646)
==4438==    by 0x7D73857: js::gc::GCRuntime::beginSweepingSweepGroup(JS::GCContext*, JS::SliceBudget&) (js/src/gc/Sweeping.cpp:1712)
==4438==    by 0x7BDCA1B: sweepaction::SweepActionSequence::run(js::gc::SweepAction::Args&) (js/src/gc/Sweeping.cpp:2346)
==4438==    by 0x7D9131A: sweepaction::SweepActionForEach<js::gc::SweepGroupsIter, JSRuntime*>::run(js::gc::SweepAction::Args&) (js/src/gc/Sweeping.cpp:2381)
==4438==    by 0x7D95272: UnknownInlinedFun (js/src/gc/Sweeping.cpp:2542)
==4438==    by 0x7D95272: UnknownInlinedFun (js/src/gc/GC.cpp:4037)
==4438==    by 0x7D95272: js::gc::GCRuntime::gcCycle(bool, JS::SliceBudget const&, JS::GCReason) (js/src/gc/GC.cpp:4584)
==4438==    by 0x7D91D62: js::gc::GCRuntime::collect(bool, JS::SliceBudget const&, JS::GCReason) (js/src/gc/GC.cpp:4773)
==4438==  Block was alloc'd at
==4438==    at 0x4854C13: calloc (vg_replace_malloc.c:1675)
==4438==    by 0x4DE1592: g_malloc0 (gmem.c:133)
==4438==    by 0x4D5AA8C: g_type_create_instance (gtype.c:1872)
==4438==    by 0x4D3FAF9: g_object_constructor.lto_priv.0 (gobject.c:3039)
==4438==    by 0x4D3F85D: g_object_new_with_custom_constructor (gobject.c:2585)
==4438==    by 0x4D4122B: UnknownInlinedFun (gobject.c:2663)
==4438==    by 0x4D4122B: g_object_new_with_properties (gobject.c:2827)
==4438==    by 0x4D422A1: g_object_new (gobject.c:2476)
==4438==    by 0x30F6AFBE: ibus_attr_list_copy_format_to_rgba (ibusattrlist.c:382)
==4438==    by 0x30F92E98: UnknownInlinedFun (ibuspanelservice.c:1197)
==4438==    by 0x30F92E98: ibus_panel_service_service_method_call (ibuspanelservice.c:1266)
==4438==    by 0x4C61C01: call_in_idle_cb (gdbusconnection.c:5476)
==4438==    by 0x4DD9F4C: g_main_dispatch (gmain.c:3565)
==4438==    by 0x4DDB616: UnknownInlinedFun (gmain.c:4425)
==4438==    by 0x4DDB616: g_main_context_iterate_unlocked.isra.0 (gmain.c:4490)

Can you reproduce your problem when you restart ibus-daemon? (yes / no)

No - IME stops working in the IDE entirely when restarted from terminal. No pop-up window with the IME set to rime.

Do you see any errors when you run ibus-daemon with the verbose option?

Issue not reproducible when ibus is manually started.

Can you reproduce your problem with a new user account instead of the

current your account? (yes / no)

Yes. This is a new virtual machine created specifically to reproduce this issue.

Add any other context about the problem here.

The stack trace bears striking resemblance to a automatic bug report I found at RedHet bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2425373

Let me know if I should try to reach JetBrains support or open a similar with GNOME.

Activity

  1. cthbleachbit commented on Mar 27, 2026

    @cthbleachbit
    Author

    It looks like IBusAttrList should be a owning reference inside a IBusText.

    ibus_panel_convert_text() and ibus_input_context_convert_text() however assign floating IBusAttrList references to IBusText without sinking it. Actually doing the sink with ibus_text_set_attributes (text, new_attrs); seems to make the double-free go away, but I'm scratching my head on how the heck GJS could have freed the list during its GC sweep with a valid IBusAttrList reference (albeit floating) inside IBusText.

    diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c
    index 68d12fb5..235a2f1f 100644
    --- a/src/ibusinputcontext.c
    +++ b/src/ibusinputcontext.c
    @@ -570,8 +570,7 @@ ibus_input_context_convert_text (IBusInputContext *context,
                 g_error_free (error);
             }
             if (new_attrs) {
    -            g_object_unref (text->attrs);
    -            text->attrs = new_attrs;
    +            ibus_text_set_attributes (text, new_attrs);
             }
             break;
         case IBUS_PREEDIT_FORMAT_HINT:
    @@ -582,8 +581,7 @@ ibus_input_context_convert_text (IBusInputContext *context,
                 g_error_free (error);
             }
             if (new_attrs) {
    -            g_object_unref (text->attrs);
    -            text->attrs = new_attrs;
    +            ibus_text_set_attributes (text, new_attrs);
             }
             break;
         default:
    diff --git a/src/ibuspanelservice.c b/src/ibuspanelservice.c
    index 16229822..fb0cc64f 100644
    --- a/src/ibuspanelservice.c
    +++ b/src/ibuspanelservice.c
    @@ -1204,8 +1204,7 @@ ibus_panel_convert_text (IBusPanelService *panel,
                 g_error_free (error);
             }
             if (new_attrs) {
    -            g_object_unref (text->attrs);
    -            text->attrs = new_attrs;
    +            ibus_text_set_attributes (text, new_attrs);
             }
             break;
         case IBUS_PREEDIT_FORMAT_HINT:
    @@ -1216,8 +1215,7 @@ ibus_panel_convert_text (IBusPanelService *panel,
                 g_error_free (error);
             }
             if (new_attrs) {
    -            g_object_unref (text->attrs);
    -            text->attrs = new_attrs;
    +            ibus_text_set_attributes (text, new_attrs);
             }
             break;
         default:
    
  2. fujiwarat commented on Mar 29, 2026

    @fujiwarat
    Member

    I cannot reproduce your SEGV in Fedora:

    fujiwara-gnome-shell-20260329.mp4

    I spent time to find where is the terminal pane of Clion but noticed it in your screencast finally.

    I think replacing gnome-shell with the shell wrapper no longer work in the current Fedoras at relase because it causes another SIGTERM with a pool-spawner.
    I added a override.conf file in my screencast to make the similar behavior instead.

    Your font size was small in your video but I guess you meant MALLOC_PRESCRIBBLE

    Probably I will try to have another functional test later.
    I think "(transfer full)" is a big change and it might cause another issue AFAIR and too late stage so the milestone may be 1.5.35 as I assume this is not a regression of 1.5.34.

  3. cthbleachbit commented on Mar 29, 2026

    @cthbleachbit
    Author

    I used MALLOC_PERTURB_=2. It's a glibc tunable https://sourceware.org/glibc/manual/2.27/html_node/Memory-Allocation-Tunables.html

    Looks like your CLion is on the default new UI while I'm on the legacy UI. I can still crash the shell with the new UI, though.

    I read a bit through the GJS code where it interfaces with gobject C API in the meantime. While I can't find where gnome-shell gets a ref to IBusAttrList in its js code, GJS's handling of floating refs could be problematic in the scenario:

    • All line numbers are from GJS 5e51afd5f5615972e992a015b01924f774e4a5a8 commit.
    • gi/object.cpp:3572 ObjectInstance* ObjectInstance::new_for_gobject(JSContext* cx, GObject* gobj) is called whenever JS code needs to have a JS representation of a C gobject.
    • Within this function line 3597 gjs unconditionally ref-sinks the object.

    What I suspect is happening under current implementation:

    • From some JS code (where?) in gnome-shell, GJS obtains a floating ref to the IBusAttrList inside the IBusText. Note that the ibus_text_get_attributes() is transfer none on the attribute. At this point the list's refcount is 1 and is floating.
    • GJS ref sinks the floating ref, converting IBusAttrList to a strong ref still with refcount equal to 1.
    • Now both GJS and the enclosing IBusText have references to the IBusAttrList but the object only has refcount 1.
    • At some point one of GJS and IBusText down refs the list triggering object destruction.
    • Later the other party also releases its (now dangling) ref to the IBusAttrList and it segfaults here.

    My change makes IBusText hold a non-floating ref to the IBusAttrList. gjs will up-ref its copy through g_object_ref_sink() and maintain the correct ref count since the ref it gets is not floating anymore.

  4. cthbleachbit commented on Mar 29, 2026

    @cthbleachbit
    Author

    Strictly speaking, I can make the crash go away by just replacing 4 text->attrs = new_attrs; occurrences and thought explicitly noting ibus_text_set_attributes takes ownership of the incoming list ref would be a nice addition.

    If transfer full would affect external binding behavior I'm okay removing that annotation.

  5. cthbleachbit commented on Mar 30, 2026

    @cthbleachbit
    Author

    Without glibc perturb tunable on fc44:

    Image

    For some reason glibc on fc44 doesn't recognize _MALLOC_PERTURB anymore, but still recognizes GLIBC_TUNABLES=glibc.malloc.perturb=3. Setting this in /etc/environment and replay the same steps will consistently crash gnome-shell.

  6. cthbleachbit commented on Mar 30, 2026

    @cthbleachbit
    Author

    Also found the piece of JS code inside gnome-shell obtaining an IBusAttrList at https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/ibusCandidatePopup.js?ref_type=heads#L241

    Reproduced here for convenience:

            panelService.connect('update-preedit-text', (ps, text, cursorPosition, visible) => {
                this._preeditText.visible = visible;
                this._updateVisibility();
    
                this._preeditText.text = text.get_text();
    
                const attrs = text.get_attributes();
                if (attrs)
                    this._setTextAttributes(this._preeditText.clutter_text, attrs);
            });
    

    The text.get_attributes(); will sink the floating attribute list ref without increasing its ref count through ObjectInstance::new_for_gobject,

  7. fujiwarat commented on Mar 30, 2026

    @fujiwarat
    Member

    I used MALLOC_PERTURB_=2. It's a glibc tunable https://sourceware.org/glibc/manual/2.27/html_node/Memory-Allocation-Tunables.html

    For some reason glibc on fc44 doesn't recognize _MALLOC_PERTURB anymore, but still recognizes GLIBC_TUNABLES=glibc.malloc.perturb=3. Setting this in /etc/environment and replay the same steps will consistently crash gnome-shell.

    OK, thank you. I tried the variables but I cannot reproduce any assertion failures with gdb and journalctl in GNOME 49 (Fedora 43) and GNOME 50 (Fedora 44).

    # rpm -q gnome-shell mutter gjs ibus
    gnome-shell-50.0-1.fc44.x86_64
    mutter-50.0-1.fc44.x86_64
    gjs-1.88.0-1.fc44.x86_64
    ibus-1.5.34~rc1-4.fc44.x86_64
    
    # ps -e | grep gnome-shell
       6526 ?        00:00:25 gnome-shell
       6600 ?        00:00:00 gnome-shell-cal
    # cat /proc/6526/environ | tr "\0" "\n" | grep malloc
    GLIBC_TUNABLES=glibc.malloc.perturb=3
    

    Currently I assume the fix would be fine in IBus 1.5.35 but not 1.5.34.

  8. cthbleachbit commented on Mar 30, 2026

    @cthbleachbit
    Author

    I couldn't reproduce this anymore on 2026.1 version of rust rover as well. Probably JetBrains changed some of their UI code? but it is still reproducible on 2025.x.

    I'm fine with delaying this to 1.5.35 as long as this gets fixed (at some point). Let me reword the patch in the meantime.

  9. fujiwarat commented on Mar 31, 2026

    @fujiwarat
    Member

    I'm fine with delaying this to 1.5.35 as long as this gets fixed (at some point). Let me reword the patch in the meantime.

    Thank you for understanding the situation. I accept the stopper bugs or very tiny bugs only in this stage.

    I tried the following test code:

    % cat a.js
    #!/usr/bin/gjs
    const IBus = imports.gi.IBus;
    var text = IBus.Text.new_from_string ("test");
    text.append_attribute(IBus.AttrType.HINT,
                          IBus.AttrPreedit.WHOLE,
                          0,
                          text.get_length());
    var attrs = text.get_attributes();
    print('end ' + attrs.ref_count);
    % gdb --args gjs a.js
    
    Thread 1 "gjs" hit Breakpoint 1, ibus_text_get_attributes (text=0x5555557671f0)
        at ibus/src/ibustext.c:293
    293	    return text->attrs;
    (gdb) print text->attrs
    $1 = (IBusAttrList *) 0x555555767ba0
    (gdb) print *text->attrs
    $2 = {parent = {parent = {parent = {g_type_instance = {
              g_class = 0x555555799390}, ref_count = 1, qdata = 0x0}, flags = 0, 
          priv = 0x555555767b90}, priv = 0x555555767b80}, 
      attributes = 0x555555767be0}
    

    Seems g_object_unref() is called 4 times for that IBusAttrList and clear the object.

    I run clion-2026.1/bin/clion with en_US.UTF-8 locale because the fallback font does not reflect the UI.

    %  fc-match :lang=ja
    NotoSansCJK-VF.ttc: "Noto Sans CJK JP" "Regular"
    % ls -l /usr/lib/jvm/java-25-openjdk/lib/fonts/fallback/NotoSansCJK-VF.ttc 
    lrwxrwxrwx. 1 root root 65  3 28 10:50 /usr/lib/jvm/java-25-openjdk/lib/fonts/fallback/NotoSansCJK-VF.ttc -> /usr/share/fonts/google-noto-sans-cjk-vf-fonts/NotoSansCJK-VF.ttc
    
  10. cthbleachbit commented on Apr 7, 2026

    @cthbleachbit
    Author

    @fujiwarat Your code snippet wouldn't reproduce the floating ref problem. In ibustext.c function ibus_text_append_attribute() creates and immediately sinks a new list if it doesn't have one already. Later ibus_text_get_attributes() call from JS would call sink again and up-ref the list (maintaining the correct ref count)

    #!/usr/bin/gjs
    const IBus = imports.gi.IBus;
    var text = IBus.Text.new_from_string ("test");
    text.append_attribute(IBus.AttrType.HINT,
                          IBus.AttrPreedit.WHOLE,
                          0,
                          text.get_length());
    var attrs = text.get_attributes();
    var plain_text = text.get_text();
    

    The following tests are made with unpatched ibus on fc44. I've set breakpoints on ibus_text_get_attributes and ibus_text_get_text (mostly due to lazyness and not knowing better on how to debug gjs)

    Thread 1 "gjs" hit Breakpoint 2, ibus_text_get_attributes (text=0x5555557600d0 [IBusText])
    (gdb) print text
    $1 = 0x5555557600d0 [IBusText]
    (gdb) print *$1.attrs
    $2 = {parent = {parent = {parent = {g_type_instance = {g_class = 0x55555576d830 [g_type: IBusAttrList/IBusSerializable/IBusObject/GInitiallyUnowned]}, ref_count = 1, 
            qdata = 0x0}, flags = 0, priv = 0x555555760a30}, priv = 0x555555760a20}, attributes = 0x555555760a80}
    (gdb) c
    Continuing.
    
    Thread 1 "gjs" hit Breakpoint 1, ibus_text_get_text (text=0x5555557600d0 [IBusText]) at /usr/src/debug/ibus-1.5.34~rc1-4.fc44.x86_64/src/ibustext.c:286
    286	{
    (gdb) print *$1.attrs
    $3 = {parent = {parent = {parent = {g_type_instance = {g_class = 0x55555576d830 [g_type: IBusAttrList/IBusSerializable/IBusObject/GInitiallyUnowned]}, ref_count = 2, 
            qdata = 0x5555557608d0}, flags = 0, priv = 0x555555760a30}, priv = 0x555555760a20}, attributes = 0x555555760a80}
    (gdb) 
    

    Note that upon ibus_text_get_text the attribute list has ref-count set to 2. One inside the IBusText instance, one in the GJS runtime. Only ibus_panel_convert_text() and ibus_input_context_convert_text() leaves the attribute list floating, but both of these are static and thus not directly accessible from JS side. Unfortunately dbus signals and stuff is beyond my expertise.

    If I can find a easy way to call either of those directly from JS, I can probably prove that current code leaves a floating reference and ends up losing the list to gjs during a ibus_text_get_attributes.

  11. cthbleachbit commented on Apr 7, 2026

    @cthbleachbit
    Author

    I made myself a small test patch on top of ibus to expose ibus_panel_convert_text attached to this comment.

    0001-TEST-EXPOSE-CONVERT-TEXT.patch

    Using a slightly modified test gjs script:

    #!/usr/bin/gjs
    const IBus = imports.gi.IBus;
    const Gio = imports.gi.Gio;
    var conn = Gio.bus_get_sync(Gio.BusType.SESSION, null);
    var panel = IBus.PanelService.new(conn);
    var text = IBus.Text.new_from_string("test");
    text.append_attribute(IBus.AttrType.HINT,
                          IBus.AttrPreedit.WHOLE,
                          0,
                          text.get_length());
    
    panel.set_preedit_format(IBus.PreeditFormat.HINT);
    panel.convert_text(text); # <- floating references created here
    
    var attr = text.get_attributes();
    var plain_text = text.get_text();
    

    Running the script under gdb:

    Thread 1 "gjs" hit Breakpoint 2, ibus_text_get_attributes (text=0x5555557e0460)
    (gdb) print text
    $1 = 0x5555557e0460
    (gdb) print *$1.attrs
    $2 = {parent = {parent = {parent = {g_type_instance = {g_class = Python Exception <class 'gdb.error'>: No type named TypeNode.
    }, ref_count = 1, qdata = 0x2}, flags = 0, priv = 0x5555557e1500}, priv = 0x5555557e14f0}, 
      attributes = 0x5555557e1550}
    (gdb) c
    Continuing.
    
    Thread 1 "gjs" hit Breakpoint 1, ibus_text_get_text (text=0x5555557e0460) at /usr/src/debug/ibus-1.5.34~rc1-4.fc44.x86_64/src/ibustext.c:286
    286	{
    (gdb) print *$1.attrs
    $3 = {parent = {parent = {parent = {g_type_instance = {g_class = Python Exception <class 'gdb.error'>: No type named TypeNode.
    }, ref_count = 1, qdata = 0x5555557e0c60}, flags = 0, priv = 0x5555557e1500}, priv = 0x5555557e14f0}, 
      attributes = 0x5555557e1550}
    

    Note how the attribute list is still at ref-count 1 after ibus_text_get_attributes has made a JS-side reference. Running this script emits g_object_unref: assertion 'G_IS_OBJECT (object)' failed.

    I couldn't get gjs to actually GC far enough to crash gjs. The most violent error I've made gjs complain about when tweaking this minimal PoC is Object 0x556b17f6d2c0 of type IBusAttrList has been finalized while it was still owned by gjs, this is due to invalid memory management.

  12. fujiwarat commented on Apr 26, 2026

    @fujiwarat
    Member

    @cthbleachbit Thank you very much for your test case.
    With the first case without panel.set_preedit_format(), I can see the ref-count of IBusAttrList is 2 but I also observe g_object_unref() is called twice for the object and cleared the allocation correctly.

    With the second case with panel.set_preedit_format(), I can reproduce your issue and accept your proposal patch is valid to fix your issue.

    Now I understand your issue depends on the ibus_*_set_preedit_format() APIs however your test case changes the static function to the public for the test.
    I'd like to see your issue with the real usage but I see it needs a complicated code to access the class methods with GJS to make a class inherited IBus.InputContext and override the vfunc.

    I made a test case with Python below and also reproduced your issue but I also noticed another issue.
    The test case requires the running ibus-daemon.

    #!/usr/bin/python
    
    from gi import require_versions as gi_require_versions
    
    gi_require_versions({'IBus': '1.0', 'GLib':  '2.0', })
    from gi.repository import IBus
    from gi.repository import GLib
    
    
    text = None
    attrs = None
    
    def update_preedit_text_with_mode_cb(context, _text, cursor, visible, mode):
        global text
        global attrs
        text = _text
        attrs = _text.get_attributes()
        print('Got update-preedit-text-with-mode',
              text.get_text(), cursor, visible, mode)
    
    
    IBus.init()
    bus = IBus.Bus();
    text = IBus.Text.new_from_string('test');
    text.append_attribute(IBus.AttrType.HINT,
                          IBus.AttrPreedit.WHOLE,
                          0,
                          text.get_length());
    text_variant = text.serialize_object()
    update_preedit_variant = GLib.Variant.new_tuple(
        GLib.Variant.new_variant(text_variant),
        GLib.Variant.new_uint32(0),
        GLib.Variant.new_boolean(True),
        GLib.Variant.new_uint32(0))
    context = bus.create_input_context('test')
    context.connect('update-preedit-text-with-mode',
                    update_preedit_text_with_mode_cb)
    context.do_g_signal(context,
                        '10.0',
                        'UpdatePreeditTextWithMode',
                        update_preedit_variant)
    print('Last', attrs, text.get_text())
    

    I think the instance of IBusText also needs to be called g_object_ref_sink() before the signal emit in ibus_input_context_g_signal(). Otherwise the Python program is failed.

    I will commit this test case after this fix.

  13. 7 remaining items

  14. added theissue type on Apr 26, 2026
  15. added this to the 1.5.35 milestone on Apr 26, 2026
  16. added 9 commits that reference this issue on May 25, 2026
    2f82452
    b133853
    d586888
    6cccd40
    ed2b0d4
    e9a4db9
    f82697f
    5bbe88a
    067de1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions