Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

potential data race in getting speed of connections #58

Closed
viennadd opened this issue Jul 12, 2017 · 1 comment
Closed

potential data race in getting speed of connections #58

viennadd opened this issue Jul 12, 2017 · 1 comment
Assignees
Milestone

Comments

@viennadd
Copy link

viennadd commented Jul 12, 2017

Hi all,

Our bug scanner has reported a data race issue at text.c#L237,

in function main, search_sortlist sorts threads created by search_getspeeds,

j = search_getspeeds( search, i );
search_sortlist( search, i );

search_getspeeds returns 0 if pthread_create failed,
would it create a part of speedtest threads, then hit one pthread_create failure and returns to main function? Could it result a situation that the created threads still running and search_sortlist writes to variables used by threads in the same time?

int search_getspeeds( search_t *results, int count )
{
	.......

	while( done < count )
	{
		for( i = 0; i < count; i ++ )
		{
			if( running < results->conf->search_threads && !results[i].speed )
			{
				results[i].speed = SPEED_ACTIVE;
				results[i].speed_start_time = gettime();
				if( pthread_create( results[i].speed_thread,
					NULL, search_speedtest, &results[i] ) == 0 )
				{
					running ++;
					break;
				}
				else
				{
					return( 0 );        // hit one pthread_create failure here, but some of threads might still running
				}
			}

SourceBrella Inc.,
Alex

@ismaell
Copy link
Member

ismaell commented Jul 16, 2017

Good catch.

@ismaell ismaell added this to the v2.13 milestone Jul 16, 2017
@ismaell ismaell self-assigned this Jul 16, 2017
@ismaell ismaell modified the milestones: v2.14, v2.13 Aug 1, 2017
@ismaell ismaell modified the milestones: v2.15, v2.14 Aug 27, 2017
@ordex ordex closed this as completed in f32f404 Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants