JoeDog / siege

Siege is an http load tester and benchmarking utility
GNU General Public License v3.0
5.97k stars 385 forks source link

Potential error(e.g., deadlock) due to the unreleased lock &timer_mutex #197

Closed jenny-cheung closed 3 years ago

jenny-cheung commented 3 years ago

Dear developers: First, thank you for your checking. It seems the lock &timer_mutex hasn't been released through the program.

https://github.com/JoeDog/siege/blob/f69b44511d61db6fd3a0cd6f8684e2eef2406516/src/util.c#L230

jenny-cheung commented 3 years ago

The relevant code is shown here. Also, I search the keyword pthread_mutex_unlock(&timer_mutex); in the repo but it shows nothing matched.

void
pthread_usleep_np(unsigned long usec)
{
....;
  pthread_mutex_lock(&timer_mutex);
  err = pthread_cond_timedwait(&timer_cond, &timer_mutex, &timeout);

  pthread_setcanceltype(type,NULL);
  pthread_testcancel();  
#else
  usleep(usec);
#endif
  return;  
}
JoeDog commented 3 years ago

Does this happen on Solaris?

jenny-cheung commented 3 years ago

@JoeDog Hi, this is found by static code scanner, which warns that the lock is not released in the thread. Thank you for your checking.

https://github.com/JoeDog/siege/blob/f69b44511d61db6fd3a0cd6f8684e2eef2406516/src/util.c#L230

JoeDog commented 3 years ago

Fixed in 4.1.1

jenny-cheung commented 3 years ago

Thank you!