MDEV-31871: maria-install-db fails on MacOS
mariadb-install crashes on start when the static variable debug_sync_global of the class st_debug_sync_globals is initialized by constructor. Definition of the class st_debug_sync_globals has a data member of the type Hash_set whose implementation depends on thread-specific data associated with the key THD_KEY_mysys. This dependency results from constructor of the class Hash_set that runs my_hash_init2() which in turn invokes my_malloc. The thread-specific data value associated with the key THD_KEY_mysys is used by the function sf_malloc to get id of the current thread. The key THD_KEY_mysys is defined as static variable at my_thr_init.c initialized with the value -1. Proper initialization of the key THD_KEY_mysys is done with the library call pthread_key_create but it happens at the my_init() that called much later after the first time the THD_KEY_mysys() has been invoked. In according with Single Unix Specification, the effect of calling pthread_setspecific() or pthread_getspecific() with a key value not obtained from pthread_key_create() is undefined. That is the reason why mariadb-install crashes on MacOS. To fix the issue, the static variable debug_sync_global is converted to a pointer to the class st_debug_sync_globals and its instantiation is done explicitly at the function debug_sync_init() that is called at right time. This is the follow-up patch to the commits 8885225d f6ecadfe where was introduced a statically instantiated object debug_sync_global of the structure st_debug_sync_globals and the key THR_KEY_mysys for this thread-specific data was initialized with the value -1.
Showing
This diff is collapsed.
Please register or sign in to comment