Skip to content

Undefined behavior due to the double releases on the lock td->io_u_lock? #1254

@true-ryan

Description

@true-ryan

Dear developers, thank you very much for your checking! It seems there is an error in the method verify_async_thread. The lock may be unlocked twice that may lead to undefined behavior. Is that true?

fio/verify.c

Line 1407 in 6202c70

pthread_mutex_lock(&td->io_u_lock);

fio/verify.c

Line 1414 in 6202c70

pthread_mutex_unlock(&td->io_u_lock);

fio/verify.c

Line 1420 in 6202c70

pthread_mutex_unlock(&td->io_u_lock);

static void *verify_async_thread(void *data)
{
	...;
		pthread_mutex_lock(&td->io_u_lock);

		while (flist_empty(&td->verify_list) &&
		       !td->verify_thread_exit) {
			ret = pthread_cond_wait(&td->verify_cond,
							&td->io_u_lock);
			if (ret) {
				pthread_mutex_unlock(&td->io_u_lock);  // release the lock and break
				break;
			}
		}

		flist_splice_init(&td->verify_list, &list);
		pthread_mutex_unlock(&td->io_u_lock); // release the lock again

		...;
}

Best,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions