Skip to content

Enable the libc++ bounded iterators in the sanitizers build #1864

Backlog

Description

@chfast

Enable the libc++ bounded iterators in the clang-libcxx-debug toolchain (the clang-latest-sanitizers job). With them, the hardening checks also cover iterators, not only operator[] and similar accessors. They would have caught the modexp span iterator bug fixed in #1863 on Linux, not only in the MSVC Debug build.

The macros that work with the distro libc++:

  • _LIBCPP_ABI_BOUNDED_ITERATORS (std::span, std::string_view)
  • _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
  • _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY
  • _LIBCPP_ABI_BOUNDED_UNIQUE_PTR

With these four, Clang 23 and the job's configuration (Release, ASan and UBSan), all unit tests and the execution-specs tests v21.0.3 pass. The build needs one test-code fix: test/utils/bytecode.hpp advances an iterator by a size_t (-Wsign-conversion).

_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING does not work: the libc++ library must be built with it, otherwise linking fails on basic_string::insert(__bounded_iter<char const*>, char).

These are ABI macros, so the Hunter packages (GTest) must be built with them too. Hunter's toolchain id does not see -D flags, so a package cached for another libc++ configuration gets reused, which violates the ODR: the unit tests crash in std::__hash_table during the GTest discovery. Setting HUNTER_TOOLCHAIN_UNDETECTABLE_ID to the flags in the toolchain file gives these packages their own toolchain id. The CircleCI Hunter cache key should also change with the toolchain file, otherwise the job keeps rebuilding the packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions