@@ -853,3 +853,54 @@ connection con2;
853853#Clean up.
854854DROP TABLE t1;
855855SET DEBUG_SYNC= 'RESET';
856+ #
857+ # Bug#19070633 - POSSIBLE ACCESS TO FREED MEMORY IN IS_FREE_LOCK() AND IS_USED_LOCK().
858+ #
859+ # Verifying issue for IS_FREE_LOCK() function.
860+ SELECT GET_LOCK("lock_19070633", 600);
861+ GET_LOCK("lock_19070633", 600)
862+ 1
863+ connect con1, localhost, root,,;
864+ # Waiting after getting user level lock info and releasing mutex.
865+ SET DEBUG_SYNC= 'after_getting_user_level_lock_info SIGNAL parked WAIT_FOR go';
866+ # Sending: SELECT IS_FREE_LOCK("lock_19070633");
867+ SELECT IS_FREE_LOCK("lock_19070633");
868+ connection default;
869+ SET DEBUG_SYNC= 'now WAIT_FOR parked';
870+ SELECT RELEASE_LOCK("lock_19070633");
871+ RELEASE_LOCK("lock_19070633")
872+ 1
873+ # Signaling connection con1 after releasing the lock.
874+ # Without fix, accessing user level lock info in con1 would result in
875+ # crash or valgrind issue invalid read is reported.
876+ SET DEBUG_SYNC= 'now SIGNAL go';
877+ connection con1;
878+ # Reaping: SELECT IS_FREE_LOCK("lock_19070633");
879+ IS_FREE_LOCK("lock_19070633")
880+ 0
881+ connection default;
882+ # Verifying issue for IS_USED_LOCK() function.
883+ SELECT GET_LOCK("lock_19070633", 600);
884+ GET_LOCK("lock_19070633", 600)
885+ 1
886+ connection con1;
887+ # Waiting after getting user level lock info and releasing mutex.
888+ SET DEBUG_SYNC= 'after_getting_user_level_lock_info SIGNAL parked WAIT_FOR go';
889+ # Sending: SELECT IS_USED_LOCK("lock_19070633");
890+ SELECT IS_USED_LOCK("lock_19070633");
891+ connection default;
892+ SET DEBUG_SYNC= 'now WAIT_FOR parked';
893+ SELECT RELEASE_LOCK("lock_19070633");
894+ RELEASE_LOCK("lock_19070633")
895+ 1
896+ # Signaling connection con1 after releasing the lock.
897+ # Without fix, accessing user level lock info in con1 would result in
898+ # crash or valgrind issue invalid read is reported.
899+ SET DEBUG_SYNC= 'now SIGNAL go';
900+ connection con1;
901+ # Reaping: SELECT IS_USED_LOCK("lock_19070633");
902+ IS_USED_LOCK("lock_19070633")
903+ #
904+ connection default;
905+ SET DEBUG_SYNC= 'RESET';
906+ disconnect con1;
0 commit comments