To better catch platform-specific bugs such as MDEV-34422, per the suggestion of debarun, I implemented some debug instrumentation for the pthread_mutex_wrapper. This revealed a few places where an init() member function was invoked without a prior destroy().
For the futex-based implementations of srw_mutex, srw_lock, and sux_lock, this is not an issue, because init() on those data structures simply asserts that the contents is zero-initialized.
On systems that lack a futex-like system call (systems other than Linux, Microsoft Windows, or those served by MDEV-26476) and where pthread_mutex_init() is allocating some resources that need to be freed by pthread_mutex_destroy(), a memory leak could occur when we are repeatedly invoking pthread_mutex_init() without a pthread_mutex_destroy() in between. This could affect buf_page_t::lock, dict_index_t::lock (in a special case of ALTER TABLE...IMPORT TABLESPACE), and trx_rseg_t::latch (when innodb_undo_tablespaces is being changed; MDEV-19229).