Skip to content

Potential error(e.g., deadlock) due to the unreleased lock &rd.mutex #379

@true-ryan

Description

@true-ryan

Hi, developers:
If the pthread_create return 0,i.e., fails to create the thread, the function returns immediately with the lock rd.mutex unreleased. It is in the test folder but still worth fixing for higher quality. Thank you for your checking.

pthread_mutex_lock(&rd.mutex);

ret = pthread_create(&recv_thread, NULL, recv_fn, &rd);

The relevant code is shown here.

static int test(int use_sqthread, int regfiles)
{
	...;
	pthread_mutex_lock(&rd.mutex);  // the lock is here
	...;

	ret = pthread_create(&recv_thread, NULL, recv_fn, &rd);
	if (ret) {
		fprintf(stderr, "Thread create failed: %d\n", ret);  
		return 1;  // without releasing after returning
	}

}

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