Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 854
    • Issues 854
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 55
    • Merge requests 55
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Issues
  • #2774
Closed
Open
Issue created Sep 27, 2022 by Aleksander Morgado@aleksmContributor

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?

Assignee
Assign to
Time tracking