This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new 65108a0dd5f [branch-1.2](scanner) Fix memory out of bound in scanner scheduler (#25311) 65108a0dd5f is described below commit 65108a0dd5ff38128af5feff224178e260b88802 Author: xy720 <22125576+xy...@users.noreply.github.com> AuthorDate: Wed Oct 11 19:48:18 2023 +0800 [branch-1.2](scanner) Fix memory out of bound in scanner scheduler (#25311) --- be/src/vec/exec/scan/scanner_scheduler.cpp | 4 +--- be/src/vec/exec/scan/scanner_scheduler.h | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/be/src/vec/exec/scan/scanner_scheduler.cpp b/be/src/vec/exec/scan/scanner_scheduler.cpp index 0602ca7ea1e..7b7e3aeac50 100644 --- a/be/src/vec/exec/scan/scanner_scheduler.cpp +++ b/be/src/vec/exec/scan/scanner_scheduler.cpp @@ -94,9 +94,7 @@ Status ScannerScheduler::init(ExecEnv* env) { } Status ScannerScheduler::submit(ScannerContext* ctx) { - if (ctx->queue_idx == -1) { - ctx->queue_idx = (_queue_idx++ % QUEUE_NUM); - } + ctx->queue_idx = (_queue_idx++ % QUEUE_NUM); if (!_pending_queues[ctx->queue_idx]->blocking_put(ctx)) { return Status::InternalError("failed to submit scanner context to scheduler"); } diff --git a/be/src/vec/exec/scan/scanner_scheduler.h b/be/src/vec/exec/scan/scanner_scheduler.h index 33627fe5381..f8639ba8933 100644 --- a/be/src/vec/exec/scan/scanner_scheduler.h +++ b/be/src/vec/exec/scan/scanner_scheduler.h @@ -68,10 +68,11 @@ private: static const int QUEUE_NUM = 4; // The ScannerContext will be submitted to the pending queue roundrobin. // _queue_idx pointer to the current queue. + // Use std::atomic_uint to prevent numerical overflow from memory out of bound. // The scheduler thread will take ctx from pending queue, schedule it, // and put it to the _scheduling_map. // If any scanner finish, it will take ctx from and put it to pending queue again. - std::atomic_int _queue_idx = {0}; + std::atomic_uint _queue_idx = {0}; BlockingQueue<ScannerContext*>** _pending_queues; // scheduling thread pool --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org