summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2021-11-22 20:13:51 +0100
committerFrantisek Sumsal <frantisek@sumsal.cz>2021-11-22 20:52:56 +0100
commitf201f3447796a5424372d32b338bc3b907516c28 (patch)
tree59020d20faddad79289c828ea94bbfcdf0aee246
parentc049acb22e6af24fdb1afff867daa8bed37a86a2 (diff)
downloadsystemd-f201f3447796a5424372d32b338bc3b907516c28.tar.gz
test: suppress certain leaks reported by LSan
so we can run TEST-46 under sanitizers once again. `systemd-homed` runs fsck on home directories, which reports a memory leak we're not interested in. Let's introduce an LSan suppression file to get around this. Since the patterns in the suppression file are matched using basic substring match[0], they're a bit cumbersome, but should get the work one. [0] https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions Example leaks (as reported by TEST-46): ``` systemd-homed[1333]: ================================================================= systemd-homed[1333]: ==1333==ERROR: LeakSanitizer: detected memory leaks systemd-homed[1333]: Direct leak of 24 byte(s) in 1 object(s) allocated from: systemd-homed[1333]: #0 0x7f0c8facccd1 in calloc (/usr/lib/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.so+0xf4cd1) systemd-homed[1333]: #1 0x558d9494ff67 (/usr/bin/fsck+0x3f67) systemd-homed[1333]: Direct leak of 6 byte(s) in 1 object(s) allocated from: systemd-homed[1333]: #0 0x7f0c8fa906c1 in strdup (/usr/lib/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.so+0xb86c1) systemd-homed[1333]: #1 0x558d949518fd (/usr/bin/fsck+0x58fd) systemd-homed[1333]: SUMMARY: AddressSanitizer: 30 byte(s) leaked in 2 allocation(s). systemd-homed[1337]: ==1337==WARNING: Symbolizer was blocked from starting itself! systemd-homed[1337]: ================================================================= systemd-homed[1337]: ==1337==ERROR: LeakSanitizer: detected memory leaks systemd-homed[1337]: Direct leak of 67584 byte(s) in 1 object(s) allocated from: systemd-homed[1337]: #0 0x7f01edb84b19 (/usr/lib/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.so+0xf4b19) systemd-homed[1337]: #1 0x7f01e8326829 (/usr/bin/../lib/libLLVM-12.so+0xb46829) systemd-homed[1337]: SUMMARY: AddressSanitizer: 67584 byte(s) leaked in 1 allocation(s). ``` With the suppression file: ``` systemd-homed[1339]: ----------------------------------------------------- systemd-homed[1339]: Suppressions used: systemd-homed[1339]: count bytes template systemd-homed[1339]: 2 30 /bin/fsck$ systemd-homed[1339]: ----------------------------------------------------- systemd-homed[1343]: ==1343==WARNING: Symbolizer was blocked from starting itself! systemd-homed[1343]: ----------------------------------------------------- systemd-homed[1343]: Suppressions used: systemd-homed[1343]: count bytes template systemd-homed[1343]: 1 67584 /lib/libLLVM systemd-homed[1343]: ----------------------------------------------------- ```
-rw-r--r--test/test-functions16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/test-functions b/test/test-functions
index d3705653ae..a4b7efb5ec 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -778,9 +778,23 @@ if [[ ! -e "$ASAN_RT_PATH" ]]; then
exit 1
fi
+# Suppress certain leaks reported by LSan (either in external tools or bogus
+# ones)
+# Docs: # https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions
+#
+# - fsck is called by systemd-homed and is reporting a leak we're not interested
+# in
+# - libLLVM is a "side effect" caused by the previous fsck leak
+cat >/systemd-lsan.supp <<INNER_EOF
+leak:/bin/fsck$
+leak:/sbin/fsck$
+leak:/lib/libLLVM
+INNER_EOF
+
+DEFAULT_LSAN_OPTIONS=${LSAN_OPTIONS:-}:suppressions=/systemd-lsan.supp
DEFAULT_ASAN_OPTIONS=${ASAN_OPTIONS:-strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1}
DEFAULT_UBSAN_OPTIONS=${UBSAN_OPTIONS:-print_stacktrace=1:print_summary=1:halt_on_error=1}
-DEFAULT_ENVIRONMENT="ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS UBSAN_OPTIONS=\$DEFAULT_UBSAN_OPTIONS"
+DEFAULT_ENVIRONMENT="ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS UBSAN_OPTIONS=\$DEFAULT_UBSAN_OPTIONS LSAN_OPTIONS=\$DEFAULT_LSAN_OPTIONS"
# As right now bash is the PID 1, we can't expect PATH to have a sane value.
# Let's make one to prevent unexpected "<bin> not found" issues in the future