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
code segment access for CONSTRUCT_ON_FIRST_USE in c++20 #33804
Comments
The cc @jmarantz |
IIUC the problem here is that CONSTRUCT_ON_FIRST_USE winds up finding a different ctor than the one intended. I don't understand why the issue description suggests 'restricted memory use'. The same problem can exist without that macro -- the change in C++ library winds up making the code do the wrong thing; not much to do about that other than hope that tests cover it. I imagine it's not a very common use of CONSTRUCT_ON_FIRST_USE; but I haven't checked. A workaround would be to change the |
Restricted memory might not be precise but the map could read code segment. If we replace string view with string, it triggers OOM since it tries to allocate 2^64 - 1 bits |
That sounds good. That will leave no ambiguity about the wrong behavior due to the wrong constructor being called, but it has nothing to do with "restricted memory". |
Sure I modified the title to make it more precise. As for Fiasco, does |
A scenario to hit: |
So what you are saying is that if we have code that is not covered by unit tests, it might fail? |
Yeah it might fail if we don't cover the corner cases. Code coverage tool can't catch that. |
just to be clear, this has nothing to do with CONSTRUCT_ON_FIRST_USE. And it has nothing to do with flat_hash_map. It has to do with ambiguity in the constructor for string_view, and if you get that wrong you crash. Is that right? So I don't think this is a subtle corner case issue. |
I tried to reproduce without |
abseil/abseil-cpp#1661 suggests
CONSTRUCT_ON_FIRST_USE
could trigger restricted memory access.It looks scary to me given
CONSTRUCT_ON_FIRST_USE
is used all over the envoy.The text was updated successfully, but these errors were encountered: