diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-06-23 14:28:30 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-06-23 14:37:07 +0200 |
commit | 88c98cb2614a2893ec2ae7197a1f234b579da7a7 (patch) | |
tree | cd8b370bd90be7ac1be59df569958e4104578cd8 /test | |
parent | Merge pull request #28129 from poettering/userdb-ratelimit (diff) | |
download | systemd-88c98cb2614a2893ec2ae7197a1f234b579da7a7.tar.xz systemd-88c98cb2614a2893ec2ae7197a1f234b579da7a7.zip |
test: make sure we get PID1's stack trace on ASan/UBSan errors
As hitting an ASan/UBSan error in PID1 results in a crash (and a kernel
panic when running under qemu), we usually lose the stack trace which
makes debugging quite painful. Let's mitigate this by forwarding the
stack trace to multiple places - namely to a file and the syslog.
Diffstat (limited to 'test')
-rw-r--r-- | test/test-functions | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/test/test-functions b/test/test-functions index d57594f17b..abbe0c2e2c 100644 --- a/test/test-functions +++ b/test/test-functions @@ -914,7 +914,7 @@ EOF } create_asan_wrapper() { - local asan_wrapper default_asan_options default_ubsan_options default_environment + local asan_wrapper default_asan_options default_ubsan_options default_environment manager_environment [[ -z "$ASAN_RT_PATH" ]] && dfatal "ASAN_RT_PATH is empty, but it shouldn't be" @@ -948,12 +948,17 @@ EOF "UBSAN_OPTIONS='$default_ubsan_options'" "ASAN_RT_PATH='$ASAN_RT_PATH'" ) + manager_environment=( + "ASAN_OPTIONS='$default_asan_options:log_path=/systemd-pid1.asan.log:log_to_syslog=1'" + "UBSAN_OPTIONS='$default_ubsan_options:log_path=/systemd-pid1.ubsan.log:log_to_syslog=1'" + "ASAN_RT_PATH='$ASAN_RT_PATH'" + ) mkdir -p "${initdir:?}/etc/systemd/system.conf.d/" cat >"${initdir:?}/etc/systemd/system.conf.d/asan.conf" <<EOF [Manager] DefaultEnvironment=${default_environment[*]} -ManagerEnvironment=${default_environment[*]} +ManagerEnvironment=${manager_environment[*]} DefaultTimeoutStartSec=180s DefaultStandardOutput=journal+console EOF @@ -1002,7 +1007,7 @@ EOF set -eux export PATH="/sbin:/bin:/usr/sbin:/usr/bin" -export ${default_environment[@]} +export ${manager_environment[@]} [[ -n "\$ASAN_OPTIONS" && -n "\$UBSAN_OPTIONS" ]] exec "$ROOTLIBDIR/systemd" "\$@" @@ -1534,6 +1539,7 @@ create_empty_image_rootdir() { check_asan_reports() { local ret=0 local root="${1:?}" + local log report if get_bool "$IS_BUILT_WITH_ASAN"; then ls -l "$root" @@ -1542,12 +1548,15 @@ check_asan_reports() { ret=$((ret+1)) fi - journald_report="$(find "$root" -name "systemd-journald.*san.log*" -exec cat {} \;)" - if [[ -n "$journald_report" ]]; then - printf "%s\n" "$journald_report" - cat "$root/systemd-journald.out" || : - ret=$((ret+1)) - fi + for log in pid1 journald; do + report="$(find "$root" -name "systemd-$log.*san.log*" -exec cat {} \;)" + if [[ -n "$report" ]]; then + printf "%s\n" "$report" + # shellcheck disable=SC2015 + [[ "$log" == journald ]] && cat "$root/systemd-journald.out" || : + ret=$((ret+1)) + fi + done # May 08 13:23:31 H testleak[2907148]: SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s). pids="$( |