From f696c365a2e8d4c6d46a0a104751754da182ac7c Mon Sep 17 00:00:00 2001 From: Chunsong Feng Date: Wed, 13 Oct 2021 03:55:08 +0000 Subject: [PATCH] src/msg/dpdk: reserve funcs capacity to avoid reallocation When a new vector is added larger than then current vector capacity, it reallocates space. lamda function accesses the previous adress will cause a segment fault. Therefore, reserve sufficient funcs space to avoid reallocation. Fixes: https://tracker.ceph.com/issues/52907 Signed-off-by: Chunsong Feng --- src/msg/async/dpdk/DPDKStack.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/msg/async/dpdk/DPDKStack.h b/src/msg/async/dpdk/DPDKStack.h index acbac7b2011ba..4eb8604c7fbed 100644 --- a/src/msg/async/dpdk/DPDKStack.h +++ b/src/msg/async/dpdk/DPDKStack.h @@ -254,8 +254,9 @@ class DPDKStack : public NetworkStack { } public: - explicit DPDKStack(CephContext *cct): NetworkStack(cct) - {} + explicit DPDKStack(CephContext *cct): NetworkStack(cct) { + funcs.reserve(cct->_conf->ms_async_op_threads); + } virtual bool support_local_listen_table() const override { return true; } virtual void spawn_worker(std::function &&func) override; -- 2.39.5