qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jiri Daněk (Jira) <j...@apache.org>
Subject [jira] [Commented] (PROTON-2199) memory leak in c++ object inspect
Date Thu, 30 Apr 2020 10:46:00 GMT

    [ https://issues.apache.org/jira/browse/PROTON-2199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17096408#comment-17096408

Jiri Daněk commented on PROTON-2199:

I'll look into fixing this. Anyways, inspect() is not used in the Proton codebase itself.
There is {{struct inspectable}} which defines operator {{<<}} (correctly, without leak)
and all calls to pn_inspect in C++ binding happen through that. Could be the reason this
was not caught. Also, {{pn_string}} is on LSan suppression list as known source of leaks to
be yet investigated (in Python test suite, it does not leak in C/C++ tests). https://github.com/apache/qpid-proton/blob/c2384ecdc7b7490fa2ed95fc121d8188122661e3/tests/lsan.supp#L43

> memory leak in c++ object inspect
> ---------------------------------
>                 Key: PROTON-2199
>                 URL: https://issues.apache.org/jira/browse/PROTON-2199
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: cpp-binding
>            Reporter: Jeff Eaton
>            Priority: Major
>              Labels: easyfix
> The {{pn_ptr_base::inspect()}} function in {{cpp/src/object.cpp}} calls {{pn_string(NULL)}}
on line 36 and never frees the allocated memory with {{pn_free()}}.
> The fix is to create the std::string as a temporary variable, then free the pn_string_t,
then return the temporary std::string, like this:
> {{std::string tmp(pn_string_get(s));}}
> {{pn_free(s);}}
> {{return tmp;}}

This message was sent by Atlassian Jira

To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org

View raw message