You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory leak when using CloseCallback for HeaderClientChannel #40
Class HeaderClientChannel has a method to set CloseCallback when connection closed, which requires a naked pointer. The callback will be called in asynchronously. By normal thought, in this case, for an asynchronous callback object, developer will new a callback object, then pass the naked pointer to then function, and hope class HeaderClientChannel take the ownership, and free the callback object if necessary.
But I found in the HeaderClientChannel class, in the function
void HeaderClientChannel::messageChannelEOF(),
after called closeCallback_->channelClosed(), then, the class assigns nullptr to the pointer:
closeCallback_ = nullptr;
In this case, memory leaking is occurred.
But I think in the asynchronous case, developer haven't the responsibility to holder a callback and free them.
And no any note to say, need to delete this in the function channelClosed().
This was by design - in practice we found that we are often setting/unsetting the close callback in our connection pooling implementation based on some parameters. We want to be able to control the lifetime of the close callback outside of the headerclientchannel itself.
Definitely we could update the docs for this, users can always do a 'delete this' in channelClosed
Activity
djwatson commentedon Oct 30, 2014
This was by design - in practice we found that we are often setting/unsetting the close callback in our connection pooling implementation based on some parameters. We want to be able to control the lifetime of the close callback outside of the headerclientchannel itself.
Definitely we could update the docs for this, users can always do a 'delete this' in channelClosed
swxlion commentedon Oct 31, 2014
OK, please update the docs to tell users what them ought to do.
thrift/lib/cpp2/test/StreamingTest.cpp: fix SIOF bug and heap-use-aft…
Add e2e regression test for Cpp2Channel::writeError upgrade-teardown UAF