abseil: force using non-std types#16029
Conversation
|
@PiotrSikora this fails with: Is there any chance the WASM cpp code could use absl::string_view so we can land this change? |
We used to have support for abseil as an optional dependency, but it was removed after Envoy moved to C++17, since there was no need for it anymore (see: proxy-wasm/proxy-wasm-cpp-host#41 and proxy-wasm/proxy-wasm-cpp-sdk#38). I don't mind re-adding abseil to Proxy-Wasm C++ Host if Envoy needs it, but I'm afraid that it's going to turn into a need for abseil in Proxy-Wasm C++ SDK, which definitely shouldn't have a hard dependency on it, so we need to add it as an optional dependency, and default to cc @mathetake |
Sure this sounds reasonable to me. @envoyproxy/maintainers what do we think about this change overall? IMO it's worth it to pin to the internal types and not using the std types, especially given the recent security issue with string_view. |
|
I'm in favor of this change. Having different implementations on different platforms, with different behavior (eg nullptr allowed vs not allowed), is not good. |
|
@PiotrSikora with C++-17 I would think we'd still want absl as a dependency for some of the functionality it adds beyond what's being pulled into std::. Examples off the top of my head
I think not all of that is destined to ever go into std::. |
Note that abseil is the different one here, the rest of the C++ world doesn't accept AFAICT, MSVC doesn't allow it either (see: string_view constructor length check nullptr), so I'm a bit puzzled by your comment regarding different behavior on different platforms. FWIW, I agree that allowing
In Proxy-Wasm C++ Host code (which my comment was referring to), we were only using I'd love to use But like I said, I'm fine with accepting abseil as an optional dependency if Envoy switches back to non-std types, but that's the only justification for having it there at this point. |
Because on some platforms the abseil implementation was being used, and on some the c++17 std library was being used. IIRC, envoy-mobile needed the abseil implementation somewhere. I am not aware of any c++ std library implementation that accepts a nullptr in this case without crashing. |
libstdc++ does allow nullptr without crashing. |
Can you expand on this? I was lead to believe strlen(nullptr) results in a crash. Does the libstdc++ string_view avoid the call to strlen or have a strlen that checks for nullptr? |
|
It sounds like we don't have consensus here on whether this change is wanted or not. Do we want to adhere more to the C++ standard? Or use the built-in safety/consistency of the abseil version? If we stick with the C++ standard is there some way clang-tidy can catch a C string being passed into a string_view without wrapping? |
I prefer the safer version. I'm not concerned about the performance cost of an extra nullptr check. I don't think static analysis will in practice help much, because it doesn't know the difference between a possibly null |
|
I think that using the safer version for now is a good idea. Bonus points for reaching out to abseil about the possibility of using the nullptr safe version in the StrCat implementation. |
|
OK sounds like we are roughly agreed that we should proceed with this change. @PiotrSikora are you willing to bring back abseil support in the WASM code (as a compile time option)? |
|
OK it sounds like we have some consensus here on moving forward. @PiotrSikora are you willing to bring back the option in proxy-wasm to use abseil and then I can finish this change? Or would you prefer I do that change? |
|
@mattklein123 if you could do it, that would be great. Thanks! |
Signed-off-by: Matt Klein <mklein@lyft.com>
|
I'm coming back to this and now wasm_cpp is not the only problem, the skywalking SDK also has the same problem. I'm concerned that we may be playing whackamole here given that we support C++17. We would essentially have to force all deps to use abseil. Now that I think about it I'm not sure this is reasonable. @lizan @antoniovicente @ggreenway thoughts? |
I think that simply allowing use of |
Yes I agree, that would be a fallback position and if we want to go that route that would be fine. I think we would have to relax or linting or NOLINT all sites that use it in the core code, but I can look into that. |
Signed-off-by: Matt Klein <mklein@lyft.com>
|
@PiotrSikora @ggreenway @lizan @antoniovicente PTAL and let me know what you think. I'm happy to drop this if we think it's not worthwhile, but I think this is relatively clean and gets the job done for the most part. |
PiotrSikora
left a comment
There was a problem hiding this comment.
Thanks, I think this makes the most sense!
ggreenway
left a comment
There was a problem hiding this comment.
LGTM, modulo @PiotrSikora 's request for a comment in the linter
Signed-off-by: Matt Klein <mklein@lyft.com>
|
Merge conflict. /wait |
|
@ggreenway @PiotrSikora updated PTAL |
After envoyproxy#16029, our build breaks without this. Signed-off-by: Raul Gutierrez Segales <rgs@pinterest.com>
After #16029, our clang 11 build breaks without this. Signed-off-by: Raul Gutierrez Segales <rgs@pinterest.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
After envoyproxy#16029, our clang 11 build breaks without this. Signed-off-by: Raul Gutierrez Segales <rgs@pinterest.com>
Force using absl optional/string_view in most places. Allow use of std::string_view where
required for extensions, in particular WASM.
Risk Level: Low
Testing: Existing tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A