summaryrefslogtreecommitdiffstats
path: root/core/templates/command_queue_mt.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/templates/command_queue_mt.h')
-rw-r--r--core/templates/command_queue_mt.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/templates/command_queue_mt.h b/core/templates/command_queue_mt.h
index 0748e9cb83..1e6c6e42a9 100644
--- a/core/templates/command_queue_mt.h
+++ b/core/templates/command_queue_mt.h
@@ -370,15 +370,19 @@ class CommandQueueMT {
flush_read_ptr += 8;
CommandBase *cmd = reinterpret_cast<CommandBase *>(&command_mem[flush_read_ptr]);
cmd->call();
+
+ // Handle potential realloc due to the command and unlock allowance.
+ cmd = reinterpret_cast<CommandBase *>(&command_mem[flush_read_ptr]);
+
if (unlikely(cmd->sync)) {
sync_head++;
unlock(); // Give an opportunity to awaiters right away.
sync_cond_var.notify_all();
lock();
+ // Handle potential realloc happened during unlock.
+ cmd = reinterpret_cast<CommandBase *>(&command_mem[flush_read_ptr]);
}
- // If the command involved reallocating the buffer, the address may have changed.
- cmd = reinterpret_cast<CommandBase *>(&command_mem[flush_read_ptr]);
cmd->~CommandBase();
flush_read_ptr += size;