[libcxx-commits] [PATCH] D159171: [libc++][hardening] Remove hardening from release notes, undeprecate safe mode

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 31 02:08:12 PDT 2023


var-const created this revision.
Herald added a subscriber: arichardson.
Herald added a project: All.
var-const edited the summary of this revision.
var-const updated this revision to Diff 554940.
var-const marked 4 inline comments as done.
var-const added a comment.
Herald added a subscriber: arphaman.
var-const published this revision for review.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Address feedback



================
Comment at: libcxx/include/__config:218
 
 // Enables the hardened mode which consists of all checks intended to be used in production. Hardened mode prioritizes
 // security-critical checks that can be done with relatively little overhead in constant time. Mutually exclusive with
----------------
This might allow catching a few curious users that would be tempted to start depending on this despite the lack of documentation and release note.


================
Comment at: libcxx/include/__config:270
 #    error "Only one of _LIBCPP_ENABLE_HARDENED_MODE and _LIBCPP_ENABLE_DEBUG_MODE can be enabled."
 #  endif
 
----------------
We should also have a check (+ test) that _LIBCPP_ENABLE_ASSERTIONS is mutually exclusive with the new hardening modes.


================
Comment at: libcxx/test/libcxx/assertions/assertions_disabled.pass.cpp:12
+// _LIBCPP_ENABLE_ASSERTIONS=1 under some configurations.
+
+// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
----------------
You'll need an `XFAIL: hardening-mode={{hardened|debug}}` here.


================
Comment at: libcxx/utils/libcxx/test/params.py:295
     Parameter(
         name="long_tests",
         choices=[True, False],
----------------
We have a bunch of `assert.pass.cpp` tests (like `libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp`) that currently do stuff like:

```
// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
```

We should change those to

```
// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode && !libcpp-has-assertions
```

That way, the assertions will be tested when `_LIBCPP_ENABLE_ASSERTIONS=1` is passed.


This patch effectively maintains the status quo, making sure that the safe mode keeps working the same way as before. Hardening will target the next major release, allowing it to go through RFC and for the implementation to stabilize and mature.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159171

Files:
  libcxx/CMakeLists.txt
  libcxx/cmake/caches/Generic-assertions.cmake
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/Hardening.rst
  libcxx/docs/ReleaseNotes/17.rst
  libcxx/docs/UsingLibcxx.rst
  libcxx/include/__config
  libcxx/include/__config_site.in
  libcxx/test/CMakeLists.txt
  libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp
  libcxx/test/libcxx/assertions/assertions_disabled.pass.cpp
  libcxx/test/libcxx/assertions/modes/debug.pass.cpp
  libcxx/test/libcxx/assertions/modes/debug_mode_disabled_in_tu.pass.cpp
  libcxx/test/libcxx/assertions/modes/debug_mode_enabled_in_tu.pass.cpp
  libcxx/test/libcxx/assertions/modes/debug_mode_not_1_or_0.verify.cpp
  libcxx/test/libcxx/assertions/modes/enable_assertions_and_debug_mutually_exclusive.verify.cpp
  libcxx/test/libcxx/assertions/modes/enable_assertions_and_hardened_mutually_exclusive.verify.cpp
  libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_hardened_mode.pass.cpp
  libcxx/test/libcxx/assertions/modes/hardened.pass.cpp
  libcxx/test/libcxx/assertions/modes/hardened_and_debug_mutually_exclusive.verify.cpp
  libcxx/test/libcxx/assertions/modes/hardened_mode_disabled_in_tu.pass.cpp
  libcxx/test/libcxx/assertions/modes/hardened_mode_enabled_in_tu.pass.cpp
  libcxx/test/libcxx/assertions/modes/hardened_mode_not_1_or_0.verify.cpp
  libcxx/test/libcxx/assertions/modes/unchecked.pass.cpp
  libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp
  libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp
  libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp
  libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/extents/assert.conversion.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/extents/assert.obs.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.conversion.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.index_operator.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_left/assert.stride.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.conversion.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.index_operator.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.stride.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/mdspan/assert.conversion.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/mdspan/assert.index_operator.pass.cpp
  libcxx/test/libcxx/containers/views/mdspan/mdspan/assert.size.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_sent.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_size.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.cons/assert.other_span.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.cons/assert.range.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp
  libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
  libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp
  libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp
  libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp
  libcxx/test/libcxx/iterators/assert.advance.pass.cpp
  libcxx/test/libcxx/iterators/assert.next.pass.cpp
  libcxx/test/libcxx/iterators/assert.prev.pass.cpp
  libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
  libcxx/test/libcxx/ranges/range.adaptors/range.drop.while/assert.begin.pass.cpp
  libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
  libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
  libcxx/test/libcxx/ranges/range.factories/range.repeat.view/ctor.piecewise.pass.cpp
  libcxx/test/libcxx/ranges/range.factories/range.repeat.view/ctor.value.bound.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
  libcxx/test/libcxx/strings/string.view/assert.ctor.length.pass.cpp
  libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp
  libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp
  libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp
  libcxx/test/libcxx/thread/thread.barrier/assert.arrive.pass.cpp
  libcxx/test/libcxx/thread/thread.barrier/assert.ctor.pass.cpp
  libcxx/test/libcxx/thread/thread.latch/assert.arrive_and_wait.pass.cpp
  libcxx/test/libcxx/thread/thread.latch/assert.count_down.pass.cpp
  libcxx/test/libcxx/thread/thread.latch/assert.ctor.pass.cpp
  libcxx/test/libcxx/thread/thread.semaphore/assert.ctor.pass.cpp
  libcxx/test/libcxx/thread/thread.semaphore/assert.release.pass.cpp
  libcxx/test/libcxx/utilities/assert.exception_guard.no_exceptions.pass.cpp
  libcxx/test/libcxx/utilities/expected/expected.expected/assert.arrow.pass.cpp
  libcxx/test/libcxx/utilities/expected/expected.expected/assert.deref.pass.cpp
  libcxx/test/libcxx/utilities/expected/expected.expected/assert.error.pass.cpp
  libcxx/test/libcxx/utilities/expected/expected.void/assert.deref.pass.cpp
  libcxx/test/libcxx/utilities/expected/expected.void/assert.error.pass.cpp
  libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp
  libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp
  libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp
  libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.pop_heap.pass.cpp
  libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.ranges_pop_heap.pass.cpp
  libcxx/test/std/utilities/utility/utility.unreachable/assert.unreachable.pass.cpp
  libcxx/test/support/test.support/test_check_assertion.pass.cpp
  libcxx/utils/ci/buildkite-pipeline.yml
  libcxx/utils/ci/run-buildbot
  libcxx/utils/libcxx/test/params.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159171.554940.patch
Type: text/x-patch
Size: 98085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230831/228dd39a/attachment-0001.bin>


More information about the libcxx-commits mailing list