From 0c8c6fcc095ff103e9adda708c1efb06fabfe08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anarthal=20=28Rub=C3=A9n=20P=C3=A9rez=29?= <34971811+anarthal@users.noreply.github.com> Date: Sun, 1 Jun 2025 13:40:37 +0200 Subject: [PATCH] Fixes a memory corruption in logger and adds sanitizer builds to CI (#261) logger now owns the prefix string This fixes a use-after-stack-return memory error in async_run Adds a clang-19 and a gcc-14 build to CI with the address and undefined behavior sanitizer enabled close #260 --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++---------- include/boost/redis/logger.hpp | 3 ++- tools/docker-compose.yml | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 102c6589..7645f33a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,49 +133,49 @@ jobs: include: - toolset: gcc-11 install: g++-11 - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '17' build-type: 'Debug' ldflags: '' - toolset: gcc-11 install: g++-11 - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '20' build-type: 'Release' ldflags: '' - toolset: clang-11 install: clang-11 - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '17' build-type: 'Debug' ldflags: '' - toolset: clang-11 install: clang-11 - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '20' build-type: 'Debug' ldflags: '' - toolset: clang-13 install: clang-13 - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '17' build-type: 'Release' ldflags: '' - toolset: clang-13 install: clang-13 - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '20' build-type: 'Release' ldflags: '' - toolset: clang-14 install: 'clang-14 libc++-14-dev libc++abi-14-dev' - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '17' build-type: 'Debug' cxxflags: '-stdlib=libc++' @@ -183,13 +183,29 @@ jobs: - toolset: clang-14 install: 'clang-14 libc++-14-dev libc++abi-14-dev' - os: ubuntu-latest + container: ubuntu:22.04 cxxstd: '20' build-type: 'Release' cxxflags: '-stdlib=libc++' ldflags: '-lc++' + + - toolset: clang-19 + install: 'clang-19' + container: ubuntu:24.04 + cxxstd: '23' + build-type: 'Debug' + cxxflags: '-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all' + ldflags: '-fsanitize=address -fsanitize=undefined' + + - toolset: gcc-14 + install: 'g++-14' + container: ubuntu:24.04 + cxxstd: '23' + build-type: 'Debug' + cxxflags: '-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all' + ldflags: '-fsanitize=address -fsanitize=undefined' - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest env: CXXFLAGS: ${{matrix.cxxflags}} -Wall -Wextra LDFLAGS: ${{matrix.ldflags}} @@ -201,7 +217,7 @@ jobs: - name: Set up the required containers run: | - docker compose -f tools/docker-compose.yml up -d --wait || (docker compose logs; exit 1) + IMAGE=${{ matrix.container }} docker compose -f tools/docker-compose.yml up -d --wait || (docker compose logs; exit 1) - name: Install dependencies run: | diff --git a/include/boost/redis/logger.hpp b/include/boost/redis/logger.hpp index a5503f1a..f4b6c668 100644 --- a/include/boost/redis/logger.hpp +++ b/include/boost/redis/logger.hpp @@ -12,6 +12,7 @@ #include #include +#include namespace boost::system { class error_code; @@ -132,7 +133,7 @@ public: private: void write_prefix(); level level_; - std::string_view prefix_; + std::string prefix_; }; } // namespace boost::redis diff --git a/tools/docker-compose.yml b/tools/docker-compose.yml index 940fc3c5..e5d81c73 100644 --- a/tools/docker-compose.yml +++ b/tools/docker-compose.yml @@ -15,7 +15,7 @@ services: - 6379:6379 - 6380:6380 builder: - image: ubuntu:22.04 + image: $IMAGE container_name: builder tty: true environment: