Floating GVariant leaks since 2.73.1 in g_object_set()
ModemManager uses gdbus-codegen generated classes to manage its DBus API. These classes use a lot of GVariants as properties, so methods generated like mm_gdbus_modem_set_supported_bands()
look like this:
void
mm_gdbus_modem_set_supported_bands (MmGdbusModem *object, GVariant *value)
{
g_object_set (G_OBJECT (object), "supported-bands", value, NULL);
}
Before 2.73.1, the user could pass a floating GVariant
(e.g. as returned by g_variant_builder_end()
) to the previous setter method, and the variant would be "consumed" by the setter, the passed floating reference would be kept by the object, and no memory leak would happen anywhere.
After 2.73.1, those floating GVariant
passed to g_object_set()
are no longer "consumed" by the setter, and end up leaking as seen in valgrind reports, see e.g. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/624
I git-bisected it to commit 95caffcd "Don't copy values during g_object_set".
Is this a regression?
Is it that the user was never expected to pass in a floating reference to g_object_set()
and assume it would end up owned by the object?