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

Fix by-value self-inclusion in C++ #1

Closed
wants to merge 2 commits into from
Closed

Conversation

ringerc
Copy link
Owner

@ringerc ringerc commented Feb 1, 2018

This IDL is fine for languages where everything is by-reference. But for C++, it tries to embed a class by-value into its self, which cannot succeed, and results in compilation failure. See jaegertracing#35

This has been worked around by patching the IDL-generated code; see jaegertracing/jaeger-client-cpp#45 .

It turns out we can just tell Thrift to include the optional member by-reference. See the comment in https://issues.apache.org/jira/browse/THRIFT-4484 about cpp.ref. Apparently that's now spelled & in Thrift IDL. I don't know what effect it has for other languages, the documentation is sparse at best, and doesn't mention this at all.

If this doesn't break other languages I think it's the correct fix for the IDL.

This IDL is fine for languages where everything is by-reference. But for C++, it tries to embed a class by-value into its self, which cannot succeed, and results in compilation failure. See jaegertracing#35

This has been worked around by patching the IDL-generated code; see jaegertracing/jaeger-client-cpp#45 .

It turns out we can just tell Thrift to include the optional member by-reference. See the comment in https://issues.apache.org/jira/browse/THRIFT-4484  about `cpp.ref`. Apparently that's now spelled `&` in Thrift IDL. I don't know what effect it has for other languages, the documentation is sparse at best, and doesn't mention this at all.

If this doesn't break other languages I think it's the correct fix for the IDL.
@@ -25,7 +25,7 @@ struct Downstream {
3: required string host
4: required string port
5: required Transport transport
6: optional Downstream downstream
6: optional Downstream &downstream

Choose a reason for hiding this comment

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

do you have a link to the documentation for this syntax?

Copy link
Owner Author

Choose a reason for hiding this comment

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

@yurishkuro I don't see it documented anywhere but that doesn't seem to be unusual for Thrift.

It's in test/Recursive.thrift per THRIFT-2421 .

But I think the implementation screwed up support for optional members. It produces bogus code that tries to dereference the __isset member not the member its self, e.g.

/home/craig/projects/2Q/opentracing-jaeger-cpp-client/src/jaegertracing/thrift-gen/tracetest_types.cpp: In member function ‘uint32_t jaegertracing::crossdock::thrift::Downstream::read(apache::thrift::protocol::TProtocol*)’:
/home/craig/projects/2Q/opentracing-jaeger-cpp-client/src/jaegertracing/thrift-gen/tracetest_types.cpp:135:41: error: ‘jaegertracing::crossdock::thrift::_Downstream__isset {aka struct jaegertracing::crossdock::thrift::_Downstream__isset}’ has no member named ‘serviceName’
           if (this->downstream->__isset.serviceName) { wasSet = true; }
                                         ^~~~~~~~~~~

Copy link
Owner Author

@ringerc ringerc Feb 2, 2018

Choose a reason for hiding this comment

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

Also, the other form, a cpp.ref annotation (https://stackoverflow.com/questions/25631235/what-is-an-annotation-in-apache-thrift-and-what-is-it-used-for) doesn't seem to do anything at all in the C++ code, and only appears in the Go tests.

@ringerc
Copy link
Owner Author

ringerc commented Feb 2, 2018

I'm abandoning this due to https://issues.apache.org/jira/browse/THRIFT-4484?focusedCommentId=16349662&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16349662 . Looks like a Thrift bug.

Instead I intend to split the Crossdock support out from jaeger cpp-client, since this problem appears to be restricted to the crossdock support related IDL. If not building with crossdock, we can pretend the problem isn't there.

@ringerc ringerc closed this Feb 2, 2018
@ringerc ringerc reopened this Aug 23, 2018
@ringerc ringerc closed this Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants