[Issue 8311][pulsar-client-cpp] In C shim, free message ID pointer after hitting callback#8312
Closed
bschofield wants to merge 2 commits intoapache:masterfrom
bschofield:bschofield/c-memoryleak
Closed
[Issue 8311][pulsar-client-cpp] In C shim, free message ID pointer after hitting callback#8312bschofield wants to merge 2 commits intoapache:masterfrom bschofield:bschofield/c-memoryleak
bschofield wants to merge 2 commits intoapache:masterfrom
bschofield:bschofield/c-memoryleak
Conversation
Contributor
Author
Contributor
|
@bschofield I agree that this is very unintuitive (and wrong from a perspective of ownership), but the problem was when this change was introduced. Right now, there is code depending on this (bad) API. If we change that, it will segfault in these apps. |
Contributor
Author
|
OK -- closing this PR in favor of a fix to the cgo interface instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8311
Motivation
The C/C++ glue code in c_Producer.cc:handle_producer_send() has a memory leak. Specifically, a
pulsar_message_id_tis created but never freed. This leaks one object for every asynchronous message send, which adds up to a big problem if sending lots of messages.Modifications
After calling the C callback,
deletethe memory allocated for thepulsar_message_id_t.Verifying this change
I have manually verified that this change fixes the leak, using valgrind.
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation