Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26561

An improper locking bug due to the unreleased lock

    XMLWordPrintable

Details

    Description

      Hi, developers, thank you for your checking. It seems the lock thd->ctrl_mutex is not correctly released if it goes to the error, so there is a missing unlock in the *error *branch

      		pthread_mutex_lock(&thd->ctrl_mutex);
       
      		if (pthread_create(&thd->id, NULL, compress_worker_thread_func,
      				   thd)) {
      			msg("compress: pthread_create() failed: "
      			    "errno = %d", errno);
      			goto err;
      		}
      	}
       
      	/* Wait for the threads to start */
      	for (i = 0; i < n; i++) {
      		comp_thread_ctxt_t *thd = threads + i;
       
      		while (thd->started == FALSE)
      			pthread_cond_wait(&thd->ctrl_cond, &thd->ctrl_mutex);
      		pthread_mutex_unlock(&thd->ctrl_mutex);
      	}
       
      	return threads;
       
      err:
      	my_free(threads);
      	return NULL;
      }
      

      https://github.com/MariaDB/server/blob/76f4a78ba2639b5abd01a88b24a3c509c11530ce/extra/mariabackup/ds_compress.cc#L364-L388

      Attachments

        Activity

          People

            danblack Daniel Black
            Ryan Ryan
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.