[all-commits] [llvm/llvm-project] 6a9c41: [libc++] Set correct size at the end of growing st...

Tacet via All-commits all-commits at lists.llvm.org
Fri Jul 14 19:00:55 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a9c41fdd4ca834a46fd866278c90a35f2375333
      https://github.com/llvm/llvm-project/commit/6a9c41fdd4ca834a46fd866278c90a35f2375333
  Author: Advenam Tacet <advenam.tacet at trailofbits.com>
  Date:   2023-07-15 (Sat, 15 Jul 2023)

  Changed paths:
    M libcxx/include/__string/extern_template_lists.h
    M libcxx/include/string

  Log Message:
  -----------
  [libc++] Set correct size at the end of growing std::string

This commit deprecates `std::basic_string::__grow_by`, which is part of ABIv1. The function is replaced by `std::basic_string:__grow_by_without_replace`, which is not part of ABI.

- The original function `__grow_by` is deprecated because it does not set the string size,  therefore it may not update the size when the size is changed, and it may also not set the size at all when the string was short initially. This leads to unpredictable size value. It is not removed or changed to avoid breaking the ABI.
- The commit adds `_LIBCPP_HIDE_FROM_ABI`  guarded by `_LIBCPP_ABI_VERSION >= 2` to `__grow_by`. This allows the function to be used in the dylib in ABIv1 without raising the `[abi:v170000]` error and removes it from future ABIs. `_LIBCPP_HIDE_FROM_ABI_AFTER_V1` cannot be used.
- Additionally, `__grow_by` has been removed from `_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST` in `libcxx/include/__string/extern_template_lists.h`.

This bugfix is necessary to implement string ASan annotations, because it mitigates the problems encountered in D132769.

Reviewed By: ldionne, #libc, philnik

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




More information about the All-commits mailing list