Repository navigation
libibus: make an IBusText own an updated IBusAttrList reference - #2890
Conversation
5c9b040 to
b52b51b
Compare
b52b51b to
9ecbd94
Compare
d586888 to
6cccd40
Compare
|
I added a test case of I may delete the |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new Python test suite (test-deserialize.py) to verify deserialization of input contexts and panels, updating the Autotools and Meson build configurations accordingly. It also refactors attribute handling in ibusinputcontext.c and ibuspanelservice.c to use ibus_text_set_attributes. The review feedback highlights critical memory leak issues: first, the GObject Introspection annotation for ibus_text_set_attributes should be (transfer none) instead of (transfer full) to prevent leaks in language bindings; second, the GDBusMethodInvocation object must be unreffed during dry-run tests to avoid leaking it. Additionally, the reviewer suggests minor cleanups in the new Python test, such as removing unnecessary semicolons and deleting an unused helper method with a typo.
| is_dry_test = !g_strcmp0 (object_path, IBUS_PATH_PANEL "/DryTest"); | ||
| if (!is_dry_test) | ||
| g_dbus_method_invocation_return_value (invocation, NULL); |
There was a problem hiding this comment.
When is_dry_test is true, g_dbus_method_invocation_return_value is not called. However, invocation is still passed as a parameter and must be completed or unreffed to avoid leaking the GDBusMethodInvocation object. Consider calling g_object_unref on invocation in the else branch.
is_dry_test = !g_strcmp0 (object_path, IBUS_PATH_PANEL "/DryTest");
if (!is_dry_test)
g_dbus_method_invocation_return_value (invocation, NULL);
else
g_object_unref (invocation);There was a problem hiding this comment.
Generally your suggestion is right but the invocation is generated by Gio.DBusMethodInvocation() in bindings/pygobject/test-deserialize.py and there is no constructor so your suggestion does not work because g_dbus_method_invocation_finalize() would be failed because of no invocation->connection if we call g_object_unref().
e9a4db9 to
f82697f
Compare
For all usages of IBusAttrList, the list is an owned reference within a IBusText struct. `ibus_panel_convert_text()` and `ibus_input_context_convert_text()` violate the invarient by assigning a **floating** IBusAttrList reference to anIBusText without sinking it. When GJS attempts to create a JS representation of an existing GObject, it unconditionally sinks the incoming reference.[1] For a non-floating reference this up-refs the object. For this floating IBusAttrLit, `g_object_ref_sink` converts it to a strong reference in-place leaving ref-count at 1. At this point the `IBusAttrList` is referenced by both the enclosing `IBusText` and the newly created GJS wrapper. When one of them is ref-downed the object is recycled, leaving the other reference dangling. To fix this we just need to maintain the list as a non-floating ref. We already have a `ibus_text_set_attributes()` that does the intended ref sinking, so just use that instead of manually assigning pointers. [1]: https://gitlab.gnome.org/GNOME/gjs/-/blob/db450465ab0161e131a92992c2509507aa6152aa/gi/object.cpp#L3597 Closes: ibus#2889
Add a test case to deserialize IBusText Closes: ibus#2889
f82697f to
067de1c
Compare
**Summary** Patches taken from: - ibus/ibus#2929 - ibus/ibus#2890 - ibus/ibus#2943 Upstream issues: - https://gitlab.gnome.org/GNOME/gnome-shell/-/work_items/9401 - https://gitlab.gnome.org/GNOME/gtk/-/work_items/8341
For all usages of IBusAttrList, the list is an owned reference within a
IBusText struct.
ibus_panel_convert_text()andibus_input_context_convert_text()violate the invariant by assigning afloating IBusAttrList reference to an IBusText without sinking it.
When GJS attempts to create a JS representation of an existing GObject,
it unconditionally sinks the incoming reference. For a non-floating
reference this up-refs the object.
For this floating IBusAttrLit,
g_object_ref_sinkconverts it to astrong reference in-place leaving ref-count at 1. At this point the
IBusAttrListis referenced by both the enclosingIBusTextand thenewly created GJS wrapper. When one of them is ref-downed the object
is recycled, leaving the other reference dangling.
To fix this we just need to maintain the list as a non-floating ref.
We already have a
ibus_text_set_attributes()that does the intendedref sinking, so just use that instead of manually assigning pointers.
Fixes #2889.