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
[Bug]: new flat_hash_map to empty string could cause memory corruption in c++20 #1661
Comments
The example code provided contains syntax errors. Sure, I could try to fix them, but then I would just be guessing what your code actually says and possibly hiding the error. Please provide a working reproduction. |
remove second const should work, sorry i try to have a minimal viable test but didn't compile again I modify the initial STR too |
I will not look at this until I have a complete reproduction. |
I'll try to have a unit test |
it's reproducible in my macOS from this commit
|
Thank you for the reproduction. This isn't an If you replace Basically this is a more complicated form of
C++20 added a new string_view constructor which is why you are seeing this issue in C++20 only. A different constructor is getting called. My only advice is not to use |
Thanks for digging on this. I filed envoyproxy/envoy#33804 |
Describe the issue
while we migrate to c++20, we see regression for flat_hash_map<absl::string_view, absl::string_view> of empty c-string. see STR for detail
Steps to reproduce the problem
while we do
where the definition is in https://github.com/envoyproxy/envoy/blob/4af52310675fbaf7d1e05cf89134332421c8ba2e/source/common/common/macros.h#L34
this will output
r.size: 1
from my side and see the element in the flat_hash_map contains lots of code section in the key of map like[Alignment = 8UL, Alloc = std::allocator<std::pair<const std::string, Envoy::Regex::EngineFactory *>
with size 2^64 -1replacing "" with string() is one workaround
What version of Abseil are you using?
version = "20230802.1",
What operating system and version are you using?
ubuntu
What compiler and version are you using?
clang 12.0.1
What build system are you using?
bazel 6.1.0
Additional context
No response
The text was updated successfully, but these errors were encountered: