The hardened mode is intended to only include security-critical,
relatively low-overhead checks that are intended to be usable in
production. By default, assertions are excluded from this mode.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG66bd177a7790: [libc++][hardening] Don't trigger uncategorized assertions in the hardened mode.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__config | ||
---|---|---|
287 | I noticed there are quite a number of cheap tests in this category. For example nullptr guards in std::string. Would it make sense to put them in a "cheap-to-test-category". Maybe a _LIBCPP_ASSERT_PRECONDITION? |
LGTM w/ UNSUPPORTED and green CI! Thanks!
libcxx/include/__config | ||
---|---|---|
287 | I suggest we discuss this in D155873. | |
libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp | ||
13 | As a follow-up patch, I think we could do this: # This, AddFeature("libcpp-has-hardened-mode") if hardening_mode == "hardened" else None, AddFeature("libcpp-has-debug-mode") if hardening_mode == "debug" else None, AddFeature("libcpp-has-unchecked-mode") if hardening_mode == "unchecked" else None, # Or that AddFeature(f"libcpp-hardening-mode={hardening_mode}") And then we could switch to // UNSUPPORTED: libcpp-has-unchecked-mode (or the other syntax). This would be a bit easier to understand. | |
15 | In this patch, I would use UNSUPPORTED here. Using XFAIL is really nice in theory because it will notify us if we forget to un-XFAIL a test after adding an assertion to the hardened mode, but unfortunately the test is UB when it's run outside of the debug mode. So in practice I think the only thing we can use consistently is UNSUPPORTED. For example you mentioned one of the barrier tests timing out. |
libcxx/include/__config | ||
---|---|---|
287 | That's fine by me. |
I noticed there are quite a number of cheap tests in this category. For example nullptr guards in std::string. Would it make sense to put them in a "cheap-to-test-category". Maybe a _LIBCPP_ASSERT_PRECONDITION?