[all-commits] [llvm/llvm-project] d0b516: [libc++] Fix an exception safety issue in `forward...

Konstantin Varlamov via All-commits all-commits at lists.llvm.org
Wed Jul 12 10:11:50 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d0b51657c259365750b3aada3bae23f19c96fdbc
  Author: varconst <varconsteq at gmail.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

  Changed paths:
    M libcxx/include/__memory/allocation_guard.h
    M libcxx/include/forward_list
    A libcxx/test/libcxx/memory/allocation_guard.pass.cpp
    M libcxx/test/std/containers/container.adaptors/from_range_container_adaptors.h
    M libcxx/test/std/containers/container.adaptors/push_range_container_adaptors.h
    A libcxx/test/std/containers/exception_safety_helpers.h
    M libcxx/test/std/containers/from_range_helpers.h
    A libcxx/test/std/containers/sequences/forwardlist/exception_safety.pass.cpp
    M libcxx/test/std/containers/sequences/from_range_sequence_containers.h
    M libcxx/test/std/containers/sequences/insert_range_sequence_containers.h

  Log Message:
  [libc++] Fix an exception safety issue in `forward_list` and add tests.

When inserting nodes into a forward list, each new node is allocated but
not constructed. The constructor was being called explicitly on the node
`value_` but the `next_` pointer remained uninitialized rather than
being set to null. This bug is only triggered in the cleanup code if an
exception is thrown -- upon successful creation of new nodes, the last
incorrect "next" value is overwritten to a correct pointer.

This issue was found due to new tests added in

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

More information about the All-commits mailing list