#hardening
5 posts tagged #hardening.
MSVC 14.52 is a long-term release, and the 14.53 preview fixes a hardening ticket
Microsoft announced MSVC 14.52 as a long-term support release. The 14.53 preview lists a fixed ticket: MSVC failed to cold-path STL hardening checks. On MSVC 19.51 a hardened out-of-bounds read stops with 0xC0000409, and a hardened gather loop loses the plain build's SSE loop.
Which checking tool catches which undefined behavior
Seven undefined statements (vector and array index, signed overflow, integer division by zero, null pointer and null unique_ptr dereference, uninitialised read) run under seven checking mechanisms on GCC 16.2: constexpr, contract_assert, _GLIBCXX_ASSERTIONS, UBSan, ASan, -ftrapv and C++26 erroneous behavior. One table of which mechanism stops, which only reports, and which says nothing. No mechanism covers every row, and none of them is an operator on a single expression.
contract_assert checks one statement, and a build flag decides what a failure does
A contract_assert placed in front of a vector access is a per-statement bounds check in C++26. On GCC 16.2 the same source ignores, reports, or terminates depending on -fcontract-evaluation-semantic, so a debug and a release build differ by one flag. libstdc++'s _GLIBCXX_ASSERTIONS is a separate mechanism that never calls the contract violation handler.
What a C++ team can actually point at when asked about memory safety
The question now arrives in procurement paperwork rather than in conference talks, and C++26 shipped without the profiles that were supposed to answer it. What exists today is less impressive and more useful: a hardened standard library measured at a fraction of a percent, sanitizers in CI, and warnings that catch the class of bug being asked about.
The hardened standard library turns an out-of-bounds read into a stop
GCC checks an out-of-bounds vector::operator[] at -O0 and stops checking at -O2, so the build you debug is guarded and the build you ship is not. One macro carries the check into the optimised build: -D_GLIBCXX_ASSERTIONS for libstdc++, _LIBCPP_HARDENING_MODE for libc++, _MSVC_STL_HARDENING for the MSVC STL. Google has reported this class of hardening cut its production segfault rate by about a third.