Bug #48197 Concurrent rw_lock_free may cause assertion failure
Submitted: 21 Oct 9:44 Modified: 23 Oct 13:27
Reporter: Yasufumi Kinoshita
Status: Verified
Category:Server: InnoDB Severity:S3 (Non-critical)
Version:5.0, 5.1, Plugin-1.0.4 OS:Any
Assigned to: Marko Mäkelä Target Version:
Tags: Contribution
Triage: Triaged: D4 (Minor)

[21 Oct 9:44] Yasufumi Kinoshita
Description:
"lock->magic_n = 0" should not be done before the lock removed from the lock list.
The other rw_lock_free() may cause the assertion error about the magic_n.

How to repeat:
It may be rare case.

Suggested fix:
move "lock->magic_n = 0;" to after the removing from rw_lock_list like mutex_free()
does.

--- innodb_plugin-1.0.4/sync/sync0rw.c     2009-05-26 22:28:49.000000000 +0900
+++ innodb_plugin-1.0.4/sync/sync0rw.c     2009-10-20 15:55:22.000000000 +0900
@@ -304,8 +304,6 @@
        ut_ad(rw_lock_validate(lock));
        ut_a(lock->lock_word == X_LOCK_DECR);

-       lock->magic_n = 0;
-
 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
        mutex_free(rw_lock_get_mutex(lock));
 #endif /* INNODB_RW_LOCKS_USE_ATOMICS */
@@ -325,6 +323,8 @@
        UT_LIST_REMOVE(list, rw_lock_list, lock);

        mutex_exit(&rw_lock_list_mutex);
+
+       lock->magic_n = 0;
 }

 #ifdef UNIV_DEBUG
[22 Oct 6:58] Yasufumi Kinoshita
It is problem for all InnoDB.
[23 Oct 13:27] Miguel Solorzano
Thank you for the bug report.