Skip to content

Commit

Permalink
MDEV-34063 tpool - integer overflow in multiplication.
Browse files Browse the repository at this point in the history
When calculating next wakeup timepoint for the timer thread, with large
thread_pool_stall_limit values, 32bit int overflow can happen.
Fixed by making one operand 8 byte large.

Also fixed the type of tick_interval to be unsigned, so it does not
go negative for very thread_pool_stall_limit.
  • Loading branch information
vaintroub committed May 3, 2024
1 parent b18259e commit 88f49da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sql/threadpool_generic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct pool_timer_t
mysql_cond_t cond;
volatile uint64 current_microtime;
std::atomic<uint64_t> next_timeout_check;
int tick_interval;
uint tick_interval;
bool shutdown;
pthread_t timer_thread_id;
};
Expand Down Expand Up @@ -577,7 +577,7 @@ static void* timer_thread(void *param)
struct timespec ts;
int err;

set_timespec_nsec(ts,timer->tick_interval*1000000);
set_timespec_nsec(ts, timer->tick_interval*1000000LL);
mysql_mutex_lock(&timer->mutex);
err= mysql_cond_timedwait(&timer->cond, &timer->mutex, &ts);
if (timer->shutdown)
Expand Down

0 comments on commit 88f49da

Please sign in to comment.