-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Add to_proto
to descriptor classes
#19971
base: main
Are you sure you want to change the base?
Conversation
There is the same name function in `upb/util/def_to_proto.c`. https://github.com/protocolbuffers/protobuf/blob/c8ad77475634f77468cd237dd10bcff978a2372a/upb/util/def_to_proto.c#L57 The amalgamation merges `upb` files into one file. So, it causes a compile error when the functions have the same name.
9f2cd99
to
964ec01
Compare
Thanks for contributing this PR, @y-yagi! The tests are really close to passing, but there seems to be an issue on macOS. Both the Ruby 3.0 and Ruby 3.4 tests are failing on macOS with a failure like this:
The same tests are passing on Linux and under FFI on the macOS, and the other descriptor tests are working as expected - it is just enum descriptor test without FFI that is having an issue. I'm going to re-run the tests now to see if the test failures are stable or if the tests are flaky. Do you have a macOS machine available to troubleshoot this on in the meantime? |
ruby/ext/google/protobuf_c/defs.c
Outdated
const char* serialized = google_protobuf_FileDescriptorProto_serialize( | ||
file_proto, arena, &size); | ||
|
||
upb_Arena_Free(arena); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking across the different implementations for the different descriptor types, some free the newly created arena and some don't.
Is there a reason not to handle them uniformly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just my miss 🙏. I fixed to free an Area in all functions.
a35588e
self->enumdef, arena); | ||
|
||
size_t size; | ||
const char* serialized = google_protobuf_EnumDescriptorProto_serialize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the error we're seeing in CI is a parse error, it might be worth being more defensive here and validating that size
is non-zero and that serialized
isn't null before calling Message_decode_bytes()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review!
I don't have a macOS so I can't reproduce this issue on my local...
I have added the validation for size
and serialized
for confirmation. 51e54e3
Could you rerun the CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. The enum descriptor test is still getting Google::Protobuf::ParseError
. And, it seems that other tests are getting the same error. I will check.
51e54e3
to
1afd9e8
Compare
I'm doubting I released an arena too early. So I fixed the timing of it. 1afd9e8 |
Some APIs (e.g. BigQuery Storage) use DescriptorProto for schema descriptions. But, in Ruby, there are no methods for that so far.
This PR implements the method for that(
to_proto
) to descriptor classes.Fixes #12044.