[all-commits] [llvm/llvm-project] 9ec809: [release/16.x][libc++] Revert the bitset sort opti...

Louis Dionne via All-commits all-commits at lists.llvm.org
Mon Apr 3 21:25:49 PDT 2023


  Branch: refs/heads/release/16.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 9ec8096d0d50a353a5bc5a91064c6332bd634021
      https://github.com/llvm/llvm-project/commit/9ec8096d0d50a353a5bc5a91064c6332bd634021
  Author: Louis Dionne <ldionne.2 at gmail.com>
  Date:   2023-04-03 (Mon, 03 Apr 2023)

  Changed paths:
    M libcxx/docs/ReleaseNotes.rst
    M libcxx/include/__algorithm/sort.h

  Log Message:
  -----------
  [release/16.x][libc++] Revert the bitset sort optimization

Part of the bitset sort optimization can cause code using an invalid
comparator to go out-of-bounds, which is potentially dangerous. This
was an unintended consequence of the original patch, or at least the
fact that we didn't have anything in place to catch that or announce
that to vendors was unintended.

More specifically, std::sort assumes that the comparison predicate is a
strict weak order (which is a pre-condition to the algorithm). However,
in practice, some predicates may not satisfy the pre-condition in subtle
ways. While that is technically a user problem, we need a good answer
for how to handle this given that we know this exists in the wild and
unconditionally reading out-of-bounds data is not a great answer. We
can't weaken the preconditions of the algorithm, however letting this
situation happen without even a way of diagnosing the issue is pretty bad.

Hence, this patch reverts the optimization from release/16.x so that we
can buy a bit of time to figure out how to properly handle and communicate
this change in the LLVM 17 release.

The bitset sort optimization was 4eddbf9f10a (aka https://llvm.org/D122780).
This patch is not a pure revert of the patch, I also fixed up the includes
a bit.

Differential Revision: https://reviews.llvm.org/D146421




More information about the All-commits mailing list