Skip to content

Commit 0c8c6fc

Browse files
authored
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
1 parent 479068e commit 0c8c6fc

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,63 +133,79 @@ jobs:
133133
include:
134134
- toolset: gcc-11
135135
install: g++-11
136-
os: ubuntu-latest
136+
container: ubuntu:22.04
137137
cxxstd: '17'
138138
build-type: 'Debug'
139139
ldflags: ''
140140

141141
- toolset: gcc-11
142142
install: g++-11
143-
os: ubuntu-latest
143+
container: ubuntu:22.04
144144
cxxstd: '20'
145145
build-type: 'Release'
146146
ldflags: ''
147147

148148
- toolset: clang-11
149149
install: clang-11
150-
os: ubuntu-latest
150+
container: ubuntu:22.04
151151
cxxstd: '17'
152152
build-type: 'Debug'
153153
ldflags: ''
154154

155155
- toolset: clang-11
156156
install: clang-11
157-
os: ubuntu-latest
157+
container: ubuntu:22.04
158158
cxxstd: '20'
159159
build-type: 'Debug'
160160
ldflags: ''
161161

162162
- toolset: clang-13
163163
install: clang-13
164-
os: ubuntu-latest
164+
container: ubuntu:22.04
165165
cxxstd: '17'
166166
build-type: 'Release'
167167
ldflags: ''
168168

169169
- toolset: clang-13
170170
install: clang-13
171-
os: ubuntu-latest
171+
container: ubuntu:22.04
172172
cxxstd: '20'
173173
build-type: 'Release'
174174
ldflags: ''
175175

176176
- toolset: clang-14
177177
install: 'clang-14 libc++-14-dev libc++abi-14-dev'
178-
os: ubuntu-latest
178+
container: ubuntu:22.04
179179
cxxstd: '17'
180180
build-type: 'Debug'
181181
cxxflags: '-stdlib=libc++'
182182
ldflags: '-lc++'
183183

184184
- toolset: clang-14
185185
install: 'clang-14 libc++-14-dev libc++abi-14-dev'
186-
os: ubuntu-latest
186+
container: ubuntu:22.04
187187
cxxstd: '20'
188188
build-type: 'Release'
189189
cxxflags: '-stdlib=libc++'
190190
ldflags: '-lc++'
191+
192+
- toolset: clang-19
193+
install: 'clang-19'
194+
container: ubuntu:24.04
195+
cxxstd: '23'
196+
build-type: 'Debug'
197+
cxxflags: '-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all'
198+
ldflags: '-fsanitize=address -fsanitize=undefined'
199+
200+
- toolset: gcc-14
201+
install: 'g++-14'
202+
container: ubuntu:24.04
203+
cxxstd: '23'
204+
build-type: 'Debug'
205+
cxxflags: '-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all'
206+
ldflags: '-fsanitize=address -fsanitize=undefined'
191207

192-
runs-on: ${{ matrix.os }}
208+
runs-on: ubuntu-latest
193209
env:
194210
CXXFLAGS: ${{matrix.cxxflags}} -Wall -Wextra
195211
LDFLAGS: ${{matrix.ldflags}}
@@ -201,7 +217,7 @@ jobs:
201217

202218
- name: Set up the required containers
203219
run: |
204-
docker compose -f tools/docker-compose.yml up -d --wait || (docker compose logs; exit 1)
220+
IMAGE=${{ matrix.container }} docker compose -f tools/docker-compose.yml up -d --wait || (docker compose logs; exit 1)
205221
206222
- name: Install dependencies
207223
run: |

include/boost/redis/logger.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <boost/asio/ip/tcp.hpp>
1313

1414
#include <string>
15+
#include <string_view>
1516

1617
namespace boost::system {
1718
class error_code;
@@ -132,7 +133,7 @@ class logger {
132133
private:
133134
void write_prefix();
134135
level level_;
135-
std::string_view prefix_;
136+
std::string prefix_;
136137
};
137138

138139
} // namespace boost::redis

tools/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
- 6379:6379
1616
- 6380:6380
1717
builder:
18-
image: ubuntu:22.04
18+
image: $IMAGE
1919
container_name: builder
2020
tty: true
2121
environment:

0 commit comments

Comments
 (0)