Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support arena allocation of google::protobuf::AnyMetadata #8758

merged 1 commit into from Jul 12, 2021


Copy link

Fixes #8264

@google-cla google-cla bot added the cla: yes label Jun 23, 2021
@@ -99,7 +99,7 @@ class Any::_Internal {
Any::Any(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_any_metadata_(&type_url_, &value_) {
_any_metadata_(arena, &type_url_, &value_) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Local regeneration of from any.proto removes some PROTOBUF_EXPORT statements from any.pb.h.
I did not included these changes into PR.

@georgthegreat georgthegreat changed the title Spupport arena allocation of google::protobuf::AnyMetadata Support arena allocation of google::protobuf::AnyMetadata Jun 23, 2021
Copy link

@georgthegreat Thanks for the fix! Looks pretty good but I have just a couple comments:

  1. I think we might as well pass Arena* as an argument to AnyMetadata::PackFrom() instead of storing it as a member variable. google::protobuf::Any has an arena member already, so this way we don't have to store it in two places.
  2. The fix has to appear in in addition to

Copy link
Contributor Author

@acozzette, this PR should fix the problem in a proper way.

Unfortunately, running protoc --cpp_out . any.proto turns into incompilable code, hence I am unable to check if code generation is ever correct.

Patches in protobuf/compiler might be incorrect.

@acozzette acozzette merged commit 7b1f793 into protocolbuffers:master Jul 12, 2021
@georgthegreat georgthegreat deleted the any-arena-leak branch July 13, 2021 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

(C++) memory leak in PackFrom() on arena-allocated Any objects
3 participants