-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Programmability
-
Fully Compatible
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When built and run with MONGO_CRYPT_UNITTEST_DYNAMIC enabled, the mongo_crypt_test.cpp unit test would dlopen() the crypt shared library and load its API functions with dlsym, through the SharedLibrary class, before running the unit tests. The code that creates the SharedLibrary class declares & initializes it inside a try/catch block, but the subsequent line of code that invokes the tests resides outside and after that try/catch block. This meant that the SharedLibrary handle we created, which manages the lifetime of the shared library, has already gone out of scope by the time the test is run. The SharedLibrary destructor also dlclose()s the shared library pointer, which means that further invocations of its functions would read unmapped memory, which results in undefined behavior or a segfault.