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

_mongoc_init_dtor() should restore its memory vtable before cleanup

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.3.5
    • Affects Version/s: 1.3.4
    • Component/s: libmongoc
    • None

      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

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

              Created:
              Updated:
              Resolved: