-
Notifications
You must be signed in to change notification settings - Fork 77
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
tracetest fails to compile in C++ #35
Comments
I haven't used C++ for a while, but isn't there a way to pre-declare the type so that you can declare a pointer to it? what does the code look like? |
I saw something called Example: struct Downstream {
//...
Downstream* downstream;
}; |
Actually, looking at the file it is clear to me that |
Original issue in Apache Thrift: apache/thrift#84. |
One last thought. The reason this only fails in C++ and not any other language relates to the way Thrift: struct Foo {
2: optional Bar bar
} C++: typedef struct _Foo__isset {
bool bar :1;
} _Foo_isset;
class Foo {
Bar bar;
_Foo__isset __isset;
void __set_bar(const Bar& b) { bar = b; __isset.bar = true; }
}; |
@yurishkuro this might block C++ client crossdock testing if it cannot be changed. |
can we fudge the generated files? Changing tracetest API is not impossible, but rather involved, we'd need to do it across all clients, unless the IDL change can be made compatible with the existing format. |
Ya that is fine with me. Might be worth noting as a "TODO." Newer versions of Thrift fix this, but not 0.9.2. |
why do you need 0.9.2? I believe you can use 0.9.3 or 0.10, they are compatible in the actual payloads, just the language APIs are different, which is not a problem for you. |
In that case why are we using it across the board when using jaeger-idl?
…On Oct 16, 2017 5:42 PM, "Yuri Shkuro" ***@***.***> wrote:
why do you need 0.9.2? I believe you can use 0.9.3 or 0.10, they are
compatible in the actual payloads, just the language APIs are different,
which is not a problem for you.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#35 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACdXeaSDl_rPNUUozDxIyg9B4KikK8O5ks5ss82zgaJpZM4P5mqF>
.
|
IIRC we only use 0.9.2 in Java, for legacy reasons. Go uses 0.9.3, JS/Python don't use Thrift at all (they use thriftrw). |
I see. Lol if I had known this before I wouldn't have bothered with
downgrading to 0.9.2 and adding it to the package manager (
hunter-packages/thrift#3). I think this might make
it easier on those relying on older versions of Thrift to integrate with
Jaeger but I might be wrong.
…On Oct 16, 2017 6:00 PM, "Yuri Shkuro" ***@***.***> wrote:
IIRC we only use 0.9.2 in Java, for legacy reasons. Go uses 0.9.3,
JS/Python don't use Thrift at all (they use thriftrw).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#35 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACdXed7yNGSYO2RFf8pGIORU4miw6zTjks5ss9IQgaJpZM4P5mqF>
.
|
is there a way to shadow/vendor thrift code in C++ so that it doesn't conflict with people's dependencies? |
Although that sounds simple, it is pretty difficult to do properly. The
package manager I have been using (Hunter) is able to do this, but I'm not
sure if most users will want to use it.
…On Oct 16, 2017 6:52 PM, "Yuri Shkuro" ***@***.***> wrote:
is there a way to shadow/vendor thrift code in C++ so that it doesn't
conflict with people's dependencies?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#35 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACdXeaC0dabJIaeh1nJFMIyH-gHtCLUAks5ss94SgaJpZM4P5mqF>
.
|
I'm wondering how this is done in any compiled language. When linking together an executable, the linker doesn't care where the symbols come from, as long as they are resolved. Even if I make a library that included the Thrift library sources, wouldn't the linker ultimately discard the symbols that it doesn't need? Example: The above case will probably drop the symbols in Thrift 0.10.0 in favor of the existing symbols in Thrift 0.9.2. |
In Java this is achieved via "shading" which rewrites the package name of the included module, e.g. instead of In Go I've seen people simply copying the vendored code into a sub-dir, which also results in a separate package name. Of course this approach only works if the shaded packages are not exposed via your module's public API. |
OK I see. Java and Go both actually define symbols with the path as a prefix/namespace. In C++ this all has to be done by hand. Unfortunately, libraries rarely do anything like that. An example of how that could be accomplished. namespace v2 {
namespace apache {
namespace thrift {
// ...
}
}
} More often they are actually included in a separate directory and linked with a different library. |
Still a problem, but fixed temporarily with this: isaachier/jaeger-client-cpp@10719ae. |
Just going to resolve this for now. |
This is different to the Thrift pull req in apache/thrift#84, since that didn't address optional self-membership. I've opened a new Thrift bug https://issues.apache.org/jira/browse/THRIFT-4484 . This blocks code-generation for the c++ library. It has to apply a manual patch to the generated code right now, making it hard to use other Thrift versions, automate builds more, etc. What would the consequences of changing how this is modeled in the IDL be? |
tracetest defines a schema for cross-language integration tests of the instrumentation libraries. Not impossible to change the schema, but the usual caveats of upgrading across 5 projects |
@yurishkuro OK, good to know. Unfortunately it looks like Ideally Thrift would just generate sane C++... |
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.
The fix to the IDL is trivial. I don't know Thrift well enough (or at all) so can't say if it will affect the wire format, but I'm guessing not? More of a concern is whether it affects the other bindings' generated code. See ringerc#1 . |
@yurishkuro reminded me a while back that the Thrift wire protocol is unlikely to change at all between minor versions of Thrift. The only changes will be the headers used etc. I only use 0.9.2 for an internal Uber project. Otherwise, if a later version supports recursive types, feel free to use that version instead. As I have pointed out before, please ignore Zipkin entirely if possible. I understand that there is a method using a Thrift type as an argument, but the argument is unused and should not be needed for compilation. |
Good to know. The latest Thrift also chokes on this IDL and produces bad
C++, though.
It looks like using a by-reference member isn't enough, Thrift generates
differently wacky C++ where it tries to access members of `__isset` e.g.
`this->downstream->__isset.serviceName`. Looking into it.
|
It looks like the problem IDL is confined to use by Crossdock, not the main protocol and project. So Jaeger should probably just patch it to something Thrift doesn't choke on. |
We need a newer Thrift to support hosts with openssl 1.1. Since Jaeger its self requires a c++11 compiler and nlohmann-json requires at least g++ 4.9, supporting newer dependencies makes sense. But Thrift 0.9.2 didn't support openssl 1.1. This is some pretty brutal surgery: - Remove crossdock and zipkin support entirely. The IDL is broken for C++ / Thrift generates bad code for it. See jaegertracing/jaeger-idl#35, https://issues.apache.org/jira/browse/THRIFT-4484 jaegertracing#45 - Adapt Thrift's namespace-aliasing approach to support Thrift built with use of std::smart_ptr or boost::smart_ptr; Thrift switched to std::smart_ptr in later versions but retains boost::smart_ptr for BC. - Regenerate IDL with Thrift 0.11.0 and commit in-tree. Unsure if Hunter still works; may need to package Thrift 0.11.0 Haven't tested with a Thrift configured with Boost smart pointers. Don't do that. The wholesale removal of zipkin and crossdock support means this is unlikely to be committable to mainline. Hopefully Thrift will fix their codegen. If not, well, we're probably going to throw Thrift out entirely soon.
This is a blocker for making the cpp-client work on a Thrift other than 0.9.2. Since Thrift 0.9.2 doesn't support openssl 1.1, it's a pretty major source of pain. The bad IDL only appears to affect Zipkin support and Crossdock support, so the impact of fixing it even if it makes a wire protocol change will only affect users of those features. Please? In the mean time I've ripped out Zipkin and Crossdock support from jaeger |
Ping @yurishkuro for practicality of removing the faulty |
I don't see the need to change the type. If anything, I heard more recent versions of Thrift support the recursive references. |
I tried it. They support the recursive references, but they generate bad
code when a recursive reference is declared 'optional'. See above-linked
Thrift bug.
I guess I could try to fix Thrift, but then we'd be stuck waiting for a
release, and I'd probably just go further down the rabbit hole.
|
When I tested Thrift 0.11.0 it produced differently wrong results. I'll check. Yeah, it does, per your comments on #94. |
tracetest.thrift declares a recursive member in its struct. I have found the generated code fails to compile in C++. It seems Thrift does not support any sort of recursive types as far as I can tell. What is the best way to fix/address this?
The text was updated successfully, but these errors were encountered: