Repository navigation
Description
Distribution and Version
Fedora 45
Desktop Environment and Version
GNOME 51.beta
Session Type
Wayland
Application and Version
gnome-shell 51.beta
IBus version
1.5.35~beta2
Issue Description
When running gnome-shell under valgrind I noticed a leak originating from ibus:
==1143602== 912 (384 direct, 528 indirect) bytes in 6 blocks are definitely lost in loss record 18,836 of 19,527
==1143602== at 0x4F24EF7: g_type_create_instance (gtype.c:1877)
==1143602== by 0x4F09277: g_object_constructor (gobject.c:3045)
==1143602== by 0x4F09831: g_object_new_with_custom_constructor (gobject.c:2591)
==1143602== by 0x4F0AE0B: g_object_new_internal (gobject.c:2669)
==1143602== by 0x4F0AE0B: g_object_new_with_properties (gobject.c:2833)
==1143602== by 0x4F0BD48: g_object_new (gobject.c:2481)
==1143602== by 0x2E5E5DB9: ibus_serializable_deserialize_object (ibusserializable.c:307)
==1143602== by 0x2E5E5F3C: ibus_text_deserialize (ibustext.c:121)
==1143602== by 0x2E5E5DCB: ibus_serializable_deserialize_object (ibusserializable.c:309)
==1143602== by 0x2E5D2FBB: ibus_input_context_g_signal (ibusinputcontext.c:639)
==1143602== by 0x4F01EB7: g_closure_invoke (gclosure.c:916)
==1143602== by 0x4F17223: signal_emit_unlocked_R.isra.0 (gsignal.c:3969)
==1143602== by 0x4F1872A: signal_emit_valist_unlocked (gsignal.c:3561)
Looking at the trace, the leaked object is a IBusAttrList.
When going through the code to find potential sources of the leak, one thing I noticed was that in ibus_input_context_convert_text() there can be duplicate ref in case of ibus_attr_list_copy_format_to_rgba() or ibus_attr_list_copy_format_to_hint() hitting the attr_list->attributes->len == 0 code path. Then both the ibus_attr_list_copy_format_to_*() function and ibus_text_set_attributes() will add a ref. Those are probably the cases where the leaks come from.
In the other case, because the the new list is created with a floating ref and ibus_text_set_attributes() will sink it, this will result in only one ref and no leak.
(I have not confirmed yet if that's actually the source of the leaks)
Steps to Reproduce
1. Run `dbus-run-session valgrind --leak-check=full --show-leak-kinds=definite gnome-shell --wayland --devkit`
2. Close the devkit window again
Alternatively follow https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/docs/building-and-running.md?ref_type=heads#running-under-valgrind-with-a-full-session to run a full session under valgrindCan you reproduce your problem when you restart ibus-daemon? (yes / no)
(not applicable)
Do you see any errors when you run ibus-daemon with the verbose option?
No response
Can you reproduce your problem with a new user account instead of the
current your account? (yes / no)
yes
Add any other context about the problem here.
I don't remember seeing this problem when I last ran valgrind on Fedora 44, i.e. ibus-1.5.34, so this is probably a somewhat recent issue.
All that is needed on the shell side for this leak to occur is:
this._ibus = IBus.Bus.new_async()this._ibus.create_input_context_async()
The issue still occurs with all other ibus code in gnome-shell commented out.
Activity
sbstnk commentedon Aug 27, 2026
Bisection points to 5bbe88a, which confirms my initial assumption.
I think this leak can be avoided by doing something like this to turn only the floating ref from the new attr list into a proper ref while leaving the
len == 0case untouched and then dropping the the ref after the text has added its own:The same change would be needed in
ibus_panel_convert_textas well.src: Fix IBusAttrList leak when converting text
[-]IBusAttrList leaks[/-][+]IBusAttrList leaks in gnome-shell[/+]fujiwarat commentedon Sep 3, 2026
Now ibus-1.5.35~beta2-2.fc45 is available.
I update a test case for this issue.
f24d13e
bindings/pygobject/test-deserialize: Update for no attribute
bindings/pygobject/test-deserialize: Update for no attribute
bindings/pygobject/test-deserialize: Update for no attribute