Repository navigation
Description
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
cthbleachbit commentedon Mar 26, 2026
Screen recording: https://www.youtube.com/watch?v=iX33KdiJIvM
cthbleachbit commentedon Mar 27, 2026
It looks like
IBusAttrListshould be a owning reference inside aIBusText.ibus_panel_convert_text()andibus_input_context_convert_text()however assign floating IBusAttrList references to IBusText without sinking it. Actually doing the sink withibus_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 validIBusAttrListreference (albeit floating) insideIBusText.fujiwarat commentedon Mar 29, 2026
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_PRESCRIBBLEProbably 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.
cthbleachbit commentedon Mar 29, 2026
I used
MALLOC_PERTURB_=2. It's a glibc tunable https://sourceware.org/glibc/manual/2.27/html_node/Memory-Allocation-Tunables.htmlLooks 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:
5e51afd5f5615972e992a015b01924f774e4a5a8commit.gi/object.cpp:3572ObjectInstance* ObjectInstance::new_for_gobject(JSContext* cx, GObject* gobj)is called whenever JS code needs to have a JS representation of a C gobject.What I suspect is happening under current implementation:
IBusAttrListinside theIBusText. Note that theibus_text_get_attributes()istransfer noneon the attribute. At this point the list's refcount is 1 and is floating.IBusAttrListto a strong ref still with refcount equal to 1.IBusTexthave references to theIBusAttrListbut the object only has refcount 1.IBusAttrListand it segfaults here.My change makes
IBusTexthold a non-floating ref to theIBusAttrList. gjs will up-ref its copy throughg_object_ref_sink()and maintain the correct ref count since the ref it gets is not floating anymore.cthbleachbit commentedon Mar 29, 2026
Strictly speaking, I can make the crash go away by just replacing 4
text->attrs = new_attrs;occurrences and thought explicitly notingibus_text_set_attributestakes ownership of the incoming list ref would be a nice addition.If
transfer fullwould affect external binding behavior I'm okay removing that annotation.cthbleachbit commentedon Mar 30, 2026
Without glibc perturb tunable on fc44:
For some reason glibc on fc44 doesn't recognize
_MALLOC_PERTURBanymore, but still recognizesGLIBC_TUNABLES=glibc.malloc.perturb=3. Setting this in/etc/environmentand replay the same steps will consistently crash gnome-shell.cthbleachbit commentedon Mar 30, 2026
Also found the piece of JS code inside
gnome-shellobtaining anIBusAttrListat https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/ibusCandidatePopup.js?ref_type=heads#L241Reproduced here for convenience:
The
text.get_attributes();will sink the floating attribute list ref without increasing its ref count throughObjectInstance::new_for_gobject,fujiwarat commentedon Mar 30, 2026
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).
Currently I assume the fix would be fine in IBus 1.5.35 but not 1.5.34.
cthbleachbit commentedon Mar 30, 2026
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.
fujiwarat commentedon Mar 31, 2026
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:
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.
cthbleachbit commentedon Apr 7, 2026
@fujiwarat Your code snippet wouldn't reproduce the floating ref problem. In
ibustext.cfunctionibus_text_append_attribute()creates and immediately sinks a new list if it doesn't have one already. Lateribus_text_get_attributes()call from JS would call sink again and up-ref the list (maintaining the correct ref count)The following tests are made with unpatched
ibuson fc44. I've set breakpoints onibus_text_get_attributesandibus_text_get_text(mostly due to lazyness and not knowing better on how to debug gjs)Note that upon
ibus_text_get_textthe attribute list has ref-count set to 2. One inside theIBusTextinstance, one in the GJS runtime. Onlyibus_panel_convert_text()andibus_input_context_convert_text()leaves the attribute list floating, but both of these arestaticand 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.cthbleachbit commentedon Apr 7, 2026
I made myself a small test patch on top of ibus to expose
ibus_panel_convert_textattached to this comment.0001-TEST-EXPOSE-CONVERT-TEXT.patch
Using a slightly modified test gjs script:
Running the script under gdb:
Note how the attribute list is still at ref-count 1 after
ibus_text_get_attributeshas made a JS-side reference. Running this script emitsg_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.fujiwarat commentedon Apr 26, 2026
@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 observeg_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.InputContextand override thevfunc.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.I think the instance of
IBusTextalso needs to be calledg_object_ref_sink()before the signal emit inibus_input_context_g_signal(). Otherwise the Python program is failed.I will commit this test case after this fix.
7 remaining items
src: make an IBusText own an updated IBusAttrList reference
bindings/pygobject: Add test-deserialize.py
bindings/pygobject: Add test-deserialize.py
Add test-deserialize.py
src: make an IBusText own an updated IBusAttrList reference
Add test-deserialize.py
Add test-deserialize.py
src: make an IBusText own an updated IBusAttrList reference
Add test-deserialize.py
sdk-deps/ibus: Update to 1.5.35-alpha1