From 6f0760beb34ab8c27df11c7ce85f1e3994d0df89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 23 Apr 2024 12:01:12 +0200 Subject: [PATCH] CommandQueueMT: Fix command cleanup (revive destructor call + plus handle buffer realloc) --- core/templates/command_queue_mt.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/templates/command_queue_mt.h b/core/templates/command_queue_mt.h index bb36f38d54e..2ad5d1229d6 100644 --- a/core/templates/command_queue_mt.h +++ b/core/templates/command_queue_mt.h @@ -302,7 +302,7 @@ class CommandQueueMT { struct CommandBase { bool sync = false; virtual void call() = 0; - virtual ~CommandBase() = default; // Won't be called. + virtual ~CommandBase() = default; }; struct SyncCommand : public CommandBase { @@ -368,6 +368,10 @@ class CommandQueueMT { sync_cond_var.notify_all(); } + // If the command involved reallocating the buffer, the address may have changed. + cmd = reinterpret_cast(&command_mem[flush_read_ptr]); + cmd->~CommandBase(); + flush_read_ptr += size; } WorkerThreadPool::thread_exit_command_queue_mt_flush();