[devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Fix definitely lost reported by valgrind. --- src/base/daemon.c | 2 -- src/log/logd/lgs_imm.cc | 8 src/log/logd/lgs_mbcsv.cc | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..56f5aa8ff 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,6 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +293,6 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..1889a57b3 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ + om_rc = saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); + if (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); +goto done; + } + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..ad98b1036 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -341,6 +341,7 @@ uint32_t edp_ed_open_stream_rec(EDU_HDL *edu_hdl, EDU_TKN *edu_tkn, } else { ckpt_open_stream_msg_ptr = static_cast(ptr); } +osafassert(ckpt_open_stream_msg_ptr != NULL); rc = m_NCS_EDU_RUN_RULES(edu_hdl, edu_tkn, ckpt_open_stream_rec_ed_rules, ckpt_open_stream_msg_ptr, ptr_data_len, buf_env, -- 2.17.1 ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Fix definitely lost reported by valgrind. --- src/base/daemon.c | 6 -- src/log/logd/lgs_imm.cc | 8 src/log/logd/lgs_mbcsv.cc | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..2b23b43c3 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,7 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; +static char internal_version_id_[53]; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +294,9 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); + strcpy(internal_version_id_, "@(#) $Id: "); + strcat(internal_version_id_, INTERNAL_VERSION_ID); + strcat(internal_version_id_, " $"); if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..1889a57b3 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ + om_rc = saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); + if (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); +goto done; + } + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..2d1271c1c 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -2502,6 +2502,7 @@ done: lgs_free_edu_mem(param->fileFmt); lgs_free_edu_mem(param->logFileCurrent); lgs_free_edu_mem(param->logStreamName); + lgs_free_edu_mem(param->dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; @@ -2813,6 +2814,7 @@ done: lgs_free_edu_mem(logFileFormat); lgs_free_edu_mem(logFileCurrent); lgs_free_edu_mem(name); + lgs_free_edu_mem(dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; -- 2.17.1 ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Fix definitely lost reported by valgrind. --- src/base/daemon.c | 5 +++-- src/log/logd/lgs_imm.cc | 7 +++ src/log/logd/lgs_mbcsv.cc | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..71eba7bff 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,7 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; +static char internal_version_id_[53]; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +294,8 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); + snprintf(internal_version_id_, 53, + "%s", "@(#) $Id: " INTERNAL_VERSION_ID " $"); if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..fd6cb9f65 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,13 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ + om_rc = saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); + if (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); + } + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..2d1271c1c 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -2502,6 +2502,7 @@ done: lgs_free_edu_mem(param->fileFmt); lgs_free_edu_mem(param->logFileCurrent); lgs_free_edu_mem(param->logStreamName); + lgs_free_edu_mem(param->dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; @@ -2813,6 +2814,7 @@ done: lgs_free_edu_mem(logFileFormat); lgs_free_edu_mem(logFileCurrent); lgs_free_edu_mem(name); + lgs_free_edu_mem(dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; -- 2.17.1 ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Hi Thang, See my comments inline. /Vu On 6/2/20 11:11 AM, thang.d.nguyen wrote: Fix definitely lost reported by valgrind. --- src/base/daemon.c | 2 -- src/log/logd/lgs_imm.cc | 8 src/log/logd/lgs_mbcsv.cc | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..56f5aa8ff 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,6 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +293,6 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); [Vu] I think this line is intentional. Refer to this commit for more info. commit 892322c6810e892e12c1042f076069c33745c6ca Author: Hans Nordeback Date: Tue Jan 7 14:57:46 2014 +0100 osaf: Improve fault analyse by using current changeset when configuring osaf [#676] Current changeset is visible in the syslog, in corefiles using ident, and also in the amfd and amfnd binaries (use ident). Updated wih review comments. if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..1889a57b3 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ + om_rc = saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); + if (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); +goto done; + } [Vu] I think the memory is freed when the search handle or om handle is finalized in below lines. I is probably mentioned in SAF spec. You can refer to it for more info. /Vu + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..ad98b1036 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -341,6 +341,7 @@ uint32_t edp_ed_open_stream_rec(EDU_HDL *edu_hdl, EDU_TKN *edu_tkn, } else { ckpt_open_stream_msg_ptr = static_cast(ptr); } +osafassert(ckpt_open_stream_msg_ptr != NULL); rc = m_NCS_EDU_RUN_RULES(edu_hdl, edu_tkn, ckpt_open_stream_rec_ed_rules, ckpt_open_stream_msg_ptr, ptr_data_len, buf_env, ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Hi Vu, Thanks for your comments. See my respond inline. B.R/Thang -Original Message- From: Vu Minh Nguyen Sent: Tuesday, June 2, 2020 12:14 PM To: Thang Duc Nguyen ; Thien Minh Huynh ; Thuan Tran ; Minh Hon Chau Cc: opensaf-devel@lists.sourceforge.net Subject: Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Hi Thang, See my comments inline. /Vu On 6/2/20 11:11 AM, thang.d.nguyen wrote: > Fix definitely lost reported by valgrind. > --- > src/base/daemon.c | 2 -- > src/log/logd/lgs_imm.cc | 8 > src/log/logd/lgs_mbcsv.cc | 1 + > 3 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/src/base/daemon.c b/src/base/daemon.c index > 48a0665f2..56f5aa8ff 100644 > --- a/src/base/daemon.c > +++ b/src/base/daemon.c > @@ -57,7 +57,6 @@ > > #define DEFAULT_RUNAS_USERNAME "opensaf" > > -static const char *internal_version_id_; > > static char fifo_file[NAME_MAX]; > static char __pidfile[NAME_MAX]; > @@ -294,7 +293,6 @@ void daemonize(int argc, char *argv[]) > char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; > char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; > > - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); [Vu] I think this line is intentional. Refer to this commit for more info. [Thang]: OK. Will keep. Will find another way. commit 892322c6810e892e12c1042f076069c33745c6ca Author: Hans Nordeback Date: Tue Jan 7 14:57:46 2014 +0100 osaf: Improve fault analyse by using current changeset when configuring osaf [#676] Current changeset is visible in the syslog, in corefiles using ident, and also in the amfd and amfnd binaries (use ident). Updated wih review comments. > > if (argc > 0 && argv != NULL) { > __parse_options(argc, argv); > diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index > 9094be5f3..1889a57b3 100644 > --- a/src/log/logd/lgs_imm.cc > +++ b/src/log/logd/lgs_imm.cc > @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { > } > > done: > + /* Free memory allocated for attribute descriptions */ om_rc = > + saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); if > + (om_rc != SA_AIS_OK) { > +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", > + saf_error(om_rc)); > +goto done; > + } [Vu] I think the memory is freed when the search handle or om handle is finalized in below lines. I is probably mentioned in SAF spec. You can refer to it for more info. [Thang]: I think these memory allocate for these attribtutes can not release by finalize. There are some services still free like that. And mem leak was reported if not free. A sample code that invoked free explicitely. You can refer to get_SaLogStreamConfig_default( ) /Vu > + > /* Do not abort if error when finalizing */ > om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); > if (om_rc != SA_AIS_OK) { > diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc > index 6ec004f0a..ad98b1036 100644 > --- a/src/log/logd/lgs_mbcsv.cc > +++ b/src/log/logd/lgs_mbcsv.cc > @@ -341,6 +341,7 @@ uint32_t edp_ed_open_stream_rec(EDU_HDL *edu_hdl, EDU_TKN > *edu_tkn, > } else { > ckpt_open_stream_msg_ptr = static_cast(ptr); > } > +osafassert(ckpt_open_stream_msg_ptr != NULL); > > rc = m_NCS_EDU_RUN_RULES(edu_hdl, edu_tkn, > ckpt_open_stream_rec_ed_rules, >ckpt_open_stream_msg_ptr, ptr_data_len, > buf_env, ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Oh, I see. Thanks Thang. On 6/2/20 2:00 PM, Thang Duc Nguyen wrote: Hi Vu, Thanks for your comments. See my respond inline. B.R/Thang -Original Message- From: Vu Minh Nguyen Sent: Tuesday, June 2, 2020 12:14 PM To: Thang Duc Nguyen ; Thien Minh Huynh ; Thuan Tran ; Minh Hon Chau Cc: opensaf-devel@lists.sourceforge.net Subject: Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Hi Thang, See my comments inline. /Vu On 6/2/20 11:11 AM, thang.d.nguyen wrote: Fix definitely lost reported by valgrind. --- src/base/daemon.c | 2 -- src/log/logd/lgs_imm.cc | 8 src/log/logd/lgs_mbcsv.cc | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..56f5aa8ff 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,6 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +293,6 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); [Vu] I think this line is intentional. Refer to this commit for more info. [Thang]: OK. Will keep. Will find another way. commit 892322c6810e892e12c1042f076069c33745c6ca Author: Hans Nordeback Date: Tue Jan 7 14:57:46 2014 +0100 osaf: Improve fault analyse by using current changeset when configuring osaf [#676] Current changeset is visible in the syslog, in corefiles using ident, and also in the amfd and amfnd binaries (use ident). Updated wih review comments. if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..1889a57b3 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ om_rc = + saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); if + (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); +goto done; + } [Vu] I think the memory is freed when the search handle or om handle is finalized in below lines. I is probably mentioned in SAF spec. You can refer to it for more info. [Thang]: I think these memory allocate for these attribtutes can not release by finalize. There are some services still free like that. And mem leak was reported if not free. A sample code that invoked free explicitely. You can refer to get_SaLogStreamConfig_default( ) /Vu + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..ad98b1036 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -341,6 +341,7 @@ uint32_t edp_ed_open_stream_rec(EDU_HDL *edu_hdl, EDU_TKN *edu_tkn, } else { ckpt_open_stream_msg_ptr = static_cast(ptr); } +osafassert(ckpt_open_stream_msg_ptr != NULL); rc = m_NCS_EDU_RUN_RULES(edu_hdl, edu_tkn, ckpt_open_stream_rec_ed_rules, ckpt_open_stream_msg_ptr, ptr_data_len, buf_env, ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Hi Thang, Some comments inline. One concern, LOG ticket but change src/base/daemon.c Is it acceptable? Or need create different ticket? Best Regards, ThuanTr -Original Message- From: Thang Duc Nguyen Sent: Tuesday, June 2, 2020 5:53 PM To: Vu Minh Nguyen ; Thien Minh Huynh ; Thuan Tran ; Minh Hon Chau Cc: opensaf-devel@lists.sourceforge.net; Thang Duc Nguyen Subject: [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Fix definitely lost reported by valgrind. --- src/base/daemon.c | 6 -- src/log/logd/lgs_imm.cc | 8 src/log/logd/lgs_mbcsv.cc | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..2b23b43c3 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,7 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; +static char internal_version_id_[53]; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +294,9 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); + strcpy(internal_version_id_, "@(#) $Id: "); + strcat(internal_version_id_, INTERNAL_VERSION_ID); + strcat(internal_version_id_, " $"); [Thuan] Can we use one line of code by snprintf(...)? if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..1889a57b3 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ + om_rc = saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); + if (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); +goto done; [Thuan] Remove "goto done;" + } + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..2d1271c1c 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -2502,6 +2502,7 @@ done: lgs_free_edu_mem(param->fileFmt); lgs_free_edu_mem(param->logFileCurrent); lgs_free_edu_mem(param->logStreamName); + lgs_free_edu_mem(param->dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; @@ -2813,6 +2814,7 @@ done: lgs_free_edu_mem(logFileFormat); lgs_free_edu_mem(logFileCurrent); lgs_free_edu_mem(name); + lgs_free_edu_mem(dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; -- 2.17.1 ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Hi Thuan, Thanks for your comment. See my respond inline. -Original Message- From: Thuan Tran Sent: Tuesday, June 9, 2020 8:40 PM To: Thang Duc Nguyen ; Vu Minh Nguyen ; Thien Minh Huynh ; Minh Hon Chau Cc: opensaf-devel@lists.sourceforge.net Subject: RE: [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Hi Thang, Some comments inline. One concern, LOG ticket but change src/base/daemon.c Is it acceptable? Or need create different ticket? [Thang]: It just modify a little so I don't want to create a new one. Let wait Minh's idea. Best Regards, ThuanTr -Original Message- From: Thang Duc Nguyen Sent: Tuesday, June 2, 2020 5:53 PM To: Vu Minh Nguyen ; Thien Minh Huynh ; Thuan Tran ; Minh Hon Chau Cc: opensaf-devel@lists.sourceforge.net; Thang Duc Nguyen Subject: [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Fix definitely lost reported by valgrind. --- src/base/daemon.c | 6 -- src/log/logd/lgs_imm.cc | 8 src/log/logd/lgs_mbcsv.cc | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..2b23b43c3 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,7 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; +static char internal_version_id_[53]; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +294,9 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); + strcpy(internal_version_id_, "@(#) $Id: "); + strcat(internal_version_id_, INTERNAL_VERSION_ID); + strcat(internal_version_id_, " $"); [Thuan] Can we use one line of code by snprintf(...)? [Thang]: OK. Will update in V3. if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..1889a57b3 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ om_rc = + saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); if + (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); +goto done; [Thuan] Remove "goto done;" [Thang]: OK. Will update in V3. + } + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..2d1271c1c 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -2502,6 +2502,7 @@ done: lgs_free_edu_mem(param->fileFmt); lgs_free_edu_mem(param->logFileCurrent); lgs_free_edu_mem(param->logStreamName); + lgs_free_edu_mem(param->dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; @@ -2813,6 +2814,7 @@ done: lgs_free_edu_mem(logFileFormat); lgs_free_edu_mem(logFileCurrent); lgs_free_edu_mem(name); + lgs_free_edu_mem(dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; -- 2.17.1 ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195]
Hi Thang, ACK. Best Regards, ThuanTr -Original Message- From: Thang Duc Nguyen Sent: Thursday, June 11, 2020 2:22 PM To: Vu Minh Nguyen ; Thien Minh Huynh ; Thuan Tran ; Minh Hon Chau Cc: opensaf-devel@lists.sourceforge.net; Thang Duc Nguyen Subject: [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Fix definitely lost reported by valgrind. --- src/base/daemon.c | 5 +++-- src/log/logd/lgs_imm.cc | 7 +++ src/log/logd/lgs_mbcsv.cc | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..71eba7bff 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,7 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; +static char internal_version_id_[53]; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +294,8 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); + snprintf(internal_version_id_, 53, + "%s", "@(#) $Id: " INTERNAL_VERSION_ID " $"); if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..fd6cb9f65 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,13 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ + om_rc = saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); + if (om_rc != SA_AIS_OK) { +LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); + } + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..2d1271c1c 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -2502,6 +2502,7 @@ done: lgs_free_edu_mem(param->fileFmt); lgs_free_edu_mem(param->logFileCurrent); lgs_free_edu_mem(param->logStreamName); + lgs_free_edu_mem(param->dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; @@ -2813,6 +2814,7 @@ done: lgs_free_edu_mem(logFileFormat); lgs_free_edu_mem(logFileCurrent); lgs_free_edu_mem(name); + lgs_free_edu_mem(dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; -- 2.17.1 ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel