[libcxx-commits] [libcxx] [libc++][ranges][abi-break] Fix `movable_box` overwriting memory of data that lives in the tail padding (PR #71314)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 22 09:24:37 PST 2023


================
@@ -166,6 +166,10 @@ ABI Affecting Changes
   to throw a different exception when attempting allocations that are too large
   (``std::bad_alloc`` vs ``std::length_error``).
 
+- The ABI of some classes inside `std::ranges` that use `movable-box` have changed in order to fix a bug which could 
+  result in overwriting user data followed  by the `movable-box`. The affected views are `take_while_view`, `filter_view`, 
+  `single_view`, `drop_while_view`, `repeat_view`, `transform_view`, `chunk_by_view`
----------------
ldionne wrote:

```suggestion
- The layout of some views inside ``std::ranges`` that use the ``movable-box`` exposition-only type as an implementation detail has changed in order to fix a bug which could result in overwriting user data following the `movable-box` <INSERT LINK TO BUG HERE>. This was caused by incorrect usage of the ``[[no_unique_address]]`` attribute inside the implementation of ``movable-box``. This only affects the layout of the following views: ``take_while_view``, ``filter_view``, 
  ``single_view``, ``drop_while_view``, ``repeat_view``, ``transform_view``, ``chunk_by_view``. In order to avoid silent breakage, an ABI tag has been added to these views such that their mangled name will be different starting in this version of libc++. As a result, attempting to call a function that expects one of these views will fail to link until the code has been rebuilt against a matching version of libc++. In practice, we believe it is unusual for these views to appear at ABI boundaries so this should not be a major problem for most users. However it is probably worth auditing ranges-heavy code for ABI boundaries that would contain these views, or for types that contain these views as members and which are passed across ABI boundaries.
```

Also, in `.rst`, code blocks require double-backticks.

https://github.com/llvm/llvm-project/pull/71314


More information about the libcxx-commits mailing list