From ae5f051faa6e2d6d1d1be69273282f4995cb569c Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Thu, 1 Apr 2021 18:04:43 +0800 Subject: [PATCH] Fix dynamic buffer bug occuring in rare condition (#1678) What I did Bug: The buffermgrd can keep adding suffix to the buffer pool reference if the buffer pool isn't found when it is being referenced. In most of the cases, it's caused by wrong configuration. Cause: In handleBufferProfileTable, the value of each field is designated by a (lvalue) reference to the object in the tuple, which means the object in the tuple will be changed if the value is changed in the function. Fix: Pass the value of each field by value instead of reference. - Why I did it Fix bug. - How I verified it Manually test. Signed-off-by: Stephen Sun stephens@nvidia.com --- cfgmgr/buffermgrdyn.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cfgmgr/buffermgrdyn.cpp b/cfgmgr/buffermgrdyn.cpp index 8ef577cc11af..fbeb9417ee4d 100644 --- a/cfgmgr/buffermgrdyn.cpp +++ b/cfgmgr/buffermgrdyn.cpp @@ -1609,8 +1609,8 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues } for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++) { - string &field = fvField(*i); - string &value = fvValue(*i); + const string &field = fvField(*i); + string value = fvValue(*i); SWSS_LOG_DEBUG("field:%s, value:%s", field.c_str(), value.c_str()); if (field == buffer_pool_field_name)