Reactivate Clang UBSan test coverage #5746
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3568.
This was briefly enabled for Clang 15 by #3452 on 2023-03-13, then disabled for Clang 16 by #3711 on 2023-05-18. After updating to Clang 20 by #5717 on 2025-09-15, we can re-enable this test coverage.
Note that
tests/utils/stl/test/features.pydisabled the configurations. We accumulated a couple of changes totests/std/tests/VSO_0000000_vector_algorithms_floats/env.lstandtests/std/tests/usual_matrix.lstcommenting out configurations, but I believe those changes were unnecessary. This PR updatesfeatures.pyto enable the feature, uncomments the commented-out configurations, and doesn't change the large number of already-uncommented configurations across other files.I audited our
env.lstand related files, and I believe our UBSan coverage is reasonably comprehensive now. For the tests it's missing from, they either have good reasons (e.g. compile-only,/clrspecific, incompatible with Clang for other reasons, etc.) or already have a blizzard of configurations where UBSan wouldn't be worth the extra cost.Notably, UBSan has never been enabled for libcxx, and I am not attempting to do so here. libcxx configurations are extremely expensive (that's why we have only three). It may be reasonable to explore this in the future, but I don't want to spend developer and machine time on that now.
I'll leave Clang UBSan disabled for the MSVC-internal test harness (this was
src/qa/VC/shared/testenv/bin/run.plin MSVC-PR-457627, for future reference). I don't know if it works now, but it would provide negative value by burning a lot of machine time when GitHub is providing sufficient coverage of the STL's product and test code.We've already merged a couple of fixes for bugs in
vector<bool>andindependent_bits_enginefound by this impending PR:<vector>: Thevector<bool>optimization forcopy()performs a forbidden negative shift #5720vector<bool>by adding missing special case #5726<random>:independent_bits_engineperforms forbidden full shifts #5719<random>: Prevent full-width shifts inindependent_bits_engine#5740⚙️ Commits
duration_cast()UB, tracked by LWG-3921.D:\GitHub\STL\out\x64\out\inc\__msvc_chrono.hpp:451:52: runtime error: signed integer overflow: 9223372036854775806 * 1000000 cannot be represented in type '_CR' (aka 'long long')#pragma pack.D:\GitHub\STL\tests\std\tests\VSO_0000000_vector_algorithms_mismatch_and_lex_compare\test.cpp:177:9: runtime error: reference binding to misaligned address 0x002ec5cfe1bb for type 'short[1]', which requires 2 byte alignmentwmemcmp()UB, reported as VSO-2583476 "wmemcmp()triggers UB with a misaligned load".C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\wchar.h:458:37: runtime error: load of misaligned address 0x7ff647c3b7bc for type 'unsigned long long', which requires 8 byte alignmentunsigned __int64 __v1 = *(unsigned __int64*)__s1;__has_feature. (I initially missed this because I was testing Clang only.)