[CDRIVER-1165] _mongoc_init_dtor() should restore its memory vtable before cleanup Created: 18/Mar/16  Updated: 30/Mar/16  Resolved: 21/Mar/16

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.3.4
Fix Version/s: 1.3.5

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-592 Deprecate mongoc_init_ctor/dtor Closed
is related to CDRIVER-1160 configure flag for MONGOC_NO_AUTOMATI... Closed
is related to PHPC-632 FPM segfaults during shutdown Closed

 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



 Comments   
Comment by Githook User [ 21/Mar/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1165: _mongoc_init_dtor() should restore its memory vtable before cleanup
Branch: r1.3
https://github.com/mongodb/mongo-c-driver/commit/95dc35baa09fcc03257d099a2d2cb6ecaf577642

Comment by Githook User [ 21/Mar/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1165: _mongoc_init_dtor() should restore its memory vtable before cleanup
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/60617779039ac323012c9e767abf864f553c63b3

Comment by Hannes Magnusson [ 21/Mar/16 ]

https://mongodbcr.appspot.com/53790002/

Generated at Wed Feb 07 21:11:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.