Fix ConstructorCallback destructor consistency issue
Summary: ConstructorCallback enables the addition of callback functions to be called when a class constructor is called (D27056139 (https://github.com/facebook/folly/commit/d31902b958fc21c7bf812b0ec45c796b4bf9073c)). The ConstructorCallback object holds a static array with all installed callbacks. When a class constructor is called, the ConstructorCallback constructor traverses the array and executes each installed callback. The array is destroyed when all instances of the class are destroyed. This diff fixes a potential concurrency issue when ConstructorCallbacks are destroyed: the callback array is destroyed while another thread is calling the class constructor and potentially looping through the callback array. We fix the issue by putting the callback array, the callback count, and the mutex into a struct and initializing a `createGlobal` object from the struct. **Facebook:** We describe the issue in more detail in T100230454. Reviewed By: bschlinker Differential Revision: D30910255 fbshipit-source-id: d345900dbadbf2e009719b6f930ab1d8aa284647
Showing
Please register or sign in to comment