[MDEV-26561] An improper locking bug due to the unreleased lock Created: 2021-09-07  Updated: 2021-11-10  Resolved: 2021-11-09

Status: Closed
Project: MariaDB Server
Component/s: mariabackup
Affects Version/s: 10.6.4
Fix Version/s: 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2

Type: Bug Priority: Major
Reporter: Ryan Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: code, performance, server
Environment:

All



 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



 Comments   
Comment by Daniel Black [ 2021-10-26 ]

Ryan, did you want to try to submit a code change?

https://mariadb.org/get-involved/getting-started-for-developers/get-code-build-test/
https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

Comment by Ryan [ 2021-10-26 ]

Sure, let me create a PR.

Comment by Daniel Black [ 2021-11-09 ]

Thanks Ryan. Will be included in next release. Sorry it missed this one, there was just a little too much higher priority work going on.

Comment by Ryan [ 2021-11-10 ]

I understand this and am very thankful for your time!

Generated at Thu Feb 08 09:46:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.