Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1165

_mongoc_init_dtor() should restore its memory vtable before cleanup

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 1.3.4
    • 1.3.5
    • libmongoc
    • None

    Description

      Restoring the BSON memory allocation vtable in _mongoc_init_dtor() (before cleanup is invoked) will ensure that any resources allocated during the ctor are freed appropriately. This will resolve PHPC-632 for those using the PHP driver with a system install of libmongoc.

      Per bjori's comment in CDRIVER-1160:

      diff --git a/src/mongoc/mongoc-init.c b/src/mongoc/mongoc-init.c
      index aee1f6e..c2e421d 100644
      --- a/src/mongoc/mongoc-init.c
      +++ b/src/mongoc/mongoc-init.c
      @@ -171,6 +171,7 @@ static void _mongoc_init_dtor (void) __attribute__((destructor));
       static void
       _mongoc_init_dtor (void)
       {
      +   bson_mem_restore_vtable ();
          mongoc_cleanup ();
       }
       #endif
      

      When embedding mongoc phongo should still compile with MONGOC_NO_AUTOMATIC_GLOBALS, but hopefully this patch can make standard mongoc shared build work

      Attachments

        Issue Links

          Activity

            People

              bjori Hannes Magnusson
              jmikola@mongodb.com Jeremy Mikola
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: