Open tommynyquist opened 2 years ago
Wonder if this is a case for std::launder()?
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive
because the last activity was over 90 days ago.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive
label was added.
This is still valid; can it be reopened?
Yes we can reopen this. @sbenzaquen can you take a look at this?
I think the problem here is with End()
, as it points past-the-end and not to a real U
.
Begin()
should always return a pointer to a valid object.
I think a solution is to calculate end via addition from a valid pointer instead. Eg
template <typename U>
U* End() const {
- int begin = BeginOffset<U>(), end = EndOffset<U>();
- if (begin == end) return nullptr;
- return reinterpret_cast<U*>(data() + end);
+ return Begin<U>() + (EndOffset<U>() - BeginOffset<U>()) / sizeof(U);
}
It might be faster if someone that can easily reproduce this issue can test the patch.
What version of protobuf and what language are you using? Version: 3.20.0 Language: C++
What operating system (Linux, Windows, ...) and version? Linux
What runtime / compiler are you using (e.g., python version or gcc version)
clang++
What did you do? Steps to reproduce the behavior:
git fetch https://chromium.googlesource.com/chromium/src refs/changes/12/3594212/24 && git cherry-pick FETCH_HEAD
gn gen out/Default --args='dcheck_always_on=true is_cfi=true is_component_build=false is_debug=false use_cfi_cast=true use_cfi_diag=true use_cfi_icall=true use_thin_lto=true'
ninja -C out/Default chrome/test:profile_proto_db_test_proto_gen
What did you expect to see A successful build.
What did you see instead? A Clang CFI issue. Example Chromium builder failure:
Anything else we should know about your project / environment N/A
Notes The following current workaround for
cfi-unrelated-cast
does not work for any classes with vtables:As part of the roll to protobuf 3.20 in Chromium, we are temporarily changing that code (diff from initial patch set) to:
This only ignores the error though.