Skip to content

Commit 3b78578

Browse files
committed
Allow mongoc_init() to not use our mm
There is a shutdown race condition in the mongoc counters segment allocation where zend mm will free the counters during RSHUTDOWN. This happens as there is no "persistent alloc" callback from the bson allocators that we can pemalloc() for. Instead, we'll let mongoc_init use its own alloctors -- but we have to remember to reset the alloc callbacks before mongoc_cleanup()
1 parent 545dc98 commit 3b78578

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

php_phongo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,10 +1674,10 @@ PHP_MINIT_FUNCTION(mongodb)
16741674

16751675
REGISTER_INI_ENTRIES();
16761676

1677-
/* Initialize libbson */
1678-
bson_mem_set_vtable(&MONGODB_G(bsonMemVTable));
16791677
/* Initialize libmongoc */
16801678
mongoc_init();
1679+
/* Initialize libbson */
1680+
bson_mem_set_vtable(&MONGODB_G(bsonMemVTable));
16811681
mongoc_log_set_handler(php_phongo_log, ctx);
16821682

16831683
/* Prep default object handlers to be used when we register the classes */
@@ -1765,6 +1765,7 @@ PHP_MSHUTDOWN_FUNCTION(mongodb)
17651765
{
17661766
(void)type; /* We don't care if we are loaded via dl() or extension= */
17671767

1768+
bson_mem_restore_vtable();
17681769
/* Cleanup after libmongoc */
17691770
mongoc_cleanup();
17701771

0 commit comments

Comments
 (0)