Bug #2154 mysqld forgets to release mutex when dying when wrong language file
Submitted: 18 Dec 2003 6:16 Modified: 28 Dec 2003 5:16
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.2 and maybe 4.0.17 OS:Linux (Linux)
Assigned to: Victor Vagin CPU Architecture:Any

[18 Dec 2003 6:16] Guilhem Bichot
Description:
see how-to-repeat

How to repeat:
[guilhem@gbichot2 mysql-4.1]$ /home/mysql_src/mysql-4.1/sql/mysqld --defaults-file=/home/mysql_src/my_master.cnf --user=guilhem --datadir=/m/data/41/1 --server-id=1 --log-bin --language=/aaaaaaa/ --skip-grant-tables --skip-innodb
031218 14:45:07  Can't find messagefile '/aaaaaaa/errmsg.sys'
031218 14:45:07  Aborting

safe_mutex: Trying to destroy unitialized mutex at item_func.cc, line 1789
Aborted

(/aaaaaaa/ does not exist on my machine).
The build was with BUILD/compile-pentium-valgrind-max.
Line 1789 is the unlock here:

void item_user_lock_free(void)
{
  hash_free(&hash_user_locks);
  pthread_mutex_destroy(&LOCK_user_locks);
}

Suggested fix:
Mutex is inited by item_init(), which is called from mysqld.cc:
  if (init_errmessage())	/* Read error messages from file */
    return 1;
  init_client_errs();
  lex_init();
  item_init();
Here init_errmessage() does not return, because it calls unireg_abort which calls clean_up() which destroys the mutex. But the mutex has not been inited (as it's inited in item_init() a few lines next).
I could not repeat it on 4.0.17 but still code looks wrong as well, because I saw the mutex being destroyed and could not see it being inited.
So 4.0.17 should be checked too.
[28 Dec 2003 5:16] Victor Vagin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

was fixed by monty 
21.12.2003