thread_group_close does not unlock mutex in error branches

Bug #1702330 reported by Laurynas Biveinis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.5
Fix Released
High
Zsolt Parragi
5.6
Fix Released
High
Zsolt Parragi
5.7
Fix Released
High
Zsolt Parragi

Bug Description

Spotted over at MariaDB:

https://github.com/MariaDB/server/pull/413

diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc
index 6075c758e405..0ffe08a80518 100644
--- a/sql/threadpool_unix.cc
+++ b/sql/threadpool_unix.cc
@@ -979,24 +979,26 @@ static void thread_group_close(thread_group_t *thread_group)

   if (pipe(thread_group->shutdown_pipe))
   {
- DBUG_VOID_RETURN;
+ goto end;
   }

   /* Wake listener */
   if (io_poll_associate_fd(thread_group->pollfd,
       thread_group->shutdown_pipe[0], NULL))
   {
- DBUG_VOID_RETURN;
+ goto end;
+ }
+ {
+ char c= 0;
+ if (write(thread_group->shutdown_pipe[1], &c, 1) < 0)
+ goto end;
   }
- char c= 0;
- if (write(thread_group->shutdown_pipe[1], &c, 1) < 0)
- DBUG_VOID_RETURN;
-
   /* Wake all workers. */
   while(wake_thread(thread_group) == 0)
   {
   }

+end:
   mysql_mutex_unlock(&thread_group->mutex);

   DBUG_VOID_RETURN;

tags: added: low-hanging-fruit threadpool
Revision history for this message
Zsolt Parragi (zsolt.parragi) wrote :
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-1103

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.