Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] Fix proxy iterator issues that trigger an assertion in Chrom…
…ium. Crash report: https://bugs.chromium.org/p/chromium/issues/detail?id=1346012 The triggered assertion is related sorting with `v8::internal::AtomicSlot`. `AtomicSlot` is a proxy iterator with a proxy type `AtomicSlot::Reference` (see https://chromium.googlesource.com/v8/v8/+/9bcb5eb590643db0c1f688fea316c7f1f4786a3c/src/objects/slots-atomic-inl.h). https://reviews.llvm.org/D130197 correctly spotted the issue in `__iter_move` but doesn't actually fix the issue. The reason is that `AtomicSlot::operator*` returns a prvalue `Reference`. After the fix in D130197, the return type of `__iter_move` is `Reference&&`. But the rvalue reference is bound to the temporary value returned by `operator*`, which will be dangling after `__iter_move` returns. The idea of the fix in this change is borrowed from C++17's move_iterator https://timsong-cpp.github.io/cppwp/n4659/move.iterators#move.iterator-1 When the underlying reference is a prvalue, we just return it by value. Differential Revision: https://reviews.llvm.org/D130212
- Loading branch information
Showing
2 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters