diff options
author | Ozan Tezcan <ozantezcan@gmail.com> | 2021-11-11 14:51:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-11 13:51:33 +0200 |
commit | b91d8b289bb64965c5eaa445809f9f49293e99c0 (patch) | |
tree | 7e921ab63b0c7535f2a13f1ed75391a01d757a26 /tests/integration | |
parent | cd6b3d558be0703b1a43f9fe58fd5f1ed7452829 (diff) | |
download | redis-b91d8b289bb64965c5eaa445809f9f49293e99c0.tar.gz |
Add sanitizer support and clean up sanitizer findings (#9601)
- Added sanitizer support. `address`, `undefined` and `thread` sanitizers are available.
- To build Redis with desired sanitizer : `make SANITIZER=undefined`
- There were some sanitizer findings, cleaned up codebase
- Added tests with address and undefined behavior sanitizers to daily CI.
- Added tests with address sanitizer to the per-PR CI (smoke out mem leaks sooner).
Basically, there are three types of issues :
**1- Unaligned load/store** : Most probably, this issue may cause a crash on a platform that
does not support unaligned access. Redis does unaligned access only on supported platforms.
**2- Signed integer overflow.** Although, signed overflow issue can be problematic time to time
and change how compiler generates code, current findings mostly about signed shift or simple
addition overflow. For most platforms Redis can be compiled for, this wouldn't cause any issue
as far as I can tell (checked generated code on godbolt.org).
**3 -Minor leak** (redis-cli), **use-after-free**(just before calling exit());
UB means nothing guaranteed and risky to reason about program behavior but I don't think any
of the fixes here worth backporting. As sanitizers are now part of the CI, preventing new issues
will be the real benefit.
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/logging.tcl | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/tests/integration/logging.tcl b/tests/integration/logging.tcl index 67306304a..2fd5efe10 100644 --- a/tests/integration/logging.tcl +++ b/tests/integration/logging.tcl @@ -1,20 +1,20 @@ tags {"external:skip"} { set system_name [string tolower [exec uname -s]] -set system_supported 0 +set backtrace_supported 0 # We only support darwin or Linux with glibc if {$system_name eq {darwin}} { - set system_supported 1 + set backtrace_supported 1 } elseif {$system_name eq {linux}} { # Avoid the test on libmusl, which does not support backtrace set ldd [exec ldd src/redis-server] if {![string match {*libc.musl*} $ldd]} { - set system_supported 1 + set backtrace_supported 1 } } -if {$system_supported} { +if {$backtrace_supported} { set server_path [tmpdir server.log] start_server [list overrides [list dir $server_path]] { test "Server is able to generate a stack trace on selected systems" { @@ -35,21 +35,34 @@ if {$system_supported} { } } } +} - # Valgrind will complain that the process terminated by a signal, skip it. - if {!$::valgrind} { - set server_path [tmpdir server1.log] - start_server [list overrides [list dir $server_path]] { - test "Crash report generated on SIGABRT" { - set pid [s process_id] - exec kill -SIGABRT $pid - set pattern "*STACK TRACE*" - set result [exec tail -1000 < [srv 0 stdout]] - assert {[string match $pattern $result]} - } +# Valgrind will complain that the process terminated by a signal, skip it. +if {!$::valgrind} { + if {$backtrace_supported} { + set crash_pattern "*STACK TRACE*" + } else { + set crash_pattern "*crashed by signal*" + } + + set server_path [tmpdir server1.log] + start_server [list overrides [list dir $server_path]] { + test "Crash report generated on SIGABRT" { + set pid [s process_id] + exec kill -SIGABRT $pid + set result [exec tail -1000 < [srv 0 stdout]] + assert {[string match $crash_pattern $result]} } } + set server_path [tmpdir server2.log] + start_server [list overrides [list dir $server_path]] { + test "Crash report generated on DEBUG SEGFAULT" { + catch {r debug segfault} + set result [exec tail -1000 < [srv 0 stdout]] + assert {[string match $crash_pattern $result]} + } + } } } |