From e4f8f99c6f4655417b01d2163a26484d57aab85d Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Wed, 7 Nov 2018 22:17:51 +0100 Subject: [PATCH 1/8] travis: install dependencies necessary for running parse-hwdb.py --- travis-ci/managers/fedora.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis-ci/managers/fedora.sh b/travis-ci/managers/fedora.sh index 3ee1105067..4feb3bc8f0 100755 --- a/travis-ci/managers/fedora.sh +++ b/travis-ci/managers/fedora.sh @@ -15,7 +15,7 @@ CONT_NAME="${CONT_NAME:-fedora-$FEDORA_RELEASE-$RANDOM}" DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}" DOCKER_RUN="${DOCKER_RUN:-docker run}" REPO_ROOT="${REPO_ROOT:-$PWD}" -ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan) +ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan python3-pyparsing python3-evdev) function info() { echo -e "\033[33;1m$1\033[0m" From 1667d63acc92ebaec56587838dd45b688325de43 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Wed, 7 Nov 2018 22:23:46 +0100 Subject: [PATCH 2/8] travis: also rebuild everything with ASan It should help to catch issues like https://github.com/systemd/systemd/issues/10677. --- travis-ci/managers/fedora.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/travis-ci/managers/fedora.sh b/travis-ci/managers/fedora.sh index 4feb3bc8f0..644d1d2f08 100755 --- a/travis-ci/managers/fedora.sh +++ b/travis-ci/managers/fedora.sh @@ -47,7 +47,11 @@ for phase in "${PHASES[@]}"; do # Build systemd $DOCKER_EXEC meson -Dslow-tests=true build $DOCKER_EXEC ninja -v -C build - # Run 'make check' + $DOCKER_EXEC ninja -C build test + + $DOCKER_EXEC git clean -dxff + $DOCKER_EXEC meson -Db_sanitize=address build + $DOCKER_EXEC ninja -v -C build $DOCKER_EXEC ninja -C build test ;; CLEANUP) From 79f6178ee1f05237074208dc832d5839ea89deb3 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Wed, 7 Nov 2018 23:01:27 +0100 Subject: [PATCH 3/8] travis: move the ASan part into a separate stage --- .travis.yml | 19 +++++++++++++++++++ travis-ci/managers/fedora.sh | 5 +++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 724504568e..add0576d47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,25 @@ jobs: after_script: - $CI_MANAGERS/fedora.sh CLEANUP + - stage: Build & test with ASan + name: Fedora Rawhide + language: bash + env: + - FEDORA_RELEASE="rawhide" + - CONT_NAME="systemd-fedora-$FEDORA_RELEASE" + - DOCKER_EXEC="docker exec -ti $CONT_NAME" + before_install: + - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce + - docker --version + install: + - $CI_MANAGERS/fedora.sh SETUP + script: + - set -e + - $CI_MANAGERS/fedora.sh RUN_ASAN + - set +e + after_script: + - $CI_MANAGERS/fedora.sh CLEANUP + - stage: Coverity language: bash env: diff --git a/travis-ci/managers/fedora.sh b/travis-ci/managers/fedora.sh index 644d1d2f08..d1ea920a1c 100755 --- a/travis-ci/managers/fedora.sh +++ b/travis-ci/managers/fedora.sh @@ -9,7 +9,7 @@ # export CONT_NAME="my-fancy-container" # travis-ci/managers/fedora.sh SETUP RUN CLEANUP -PHASES=(${@:-SETUP RUN CLEANUP}) +PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP}) FEDORA_RELEASE="${FEDORA_RELEASE:-rawhide}" CONT_NAME="${CONT_NAME:-fedora-$FEDORA_RELEASE-$RANDOM}" DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}" @@ -48,7 +48,8 @@ for phase in "${PHASES[@]}"; do $DOCKER_EXEC meson -Dslow-tests=true build $DOCKER_EXEC ninja -v -C build $DOCKER_EXEC ninja -C build test - + ;; + RUN_ASAN) $DOCKER_EXEC git clean -dxff $DOCKER_EXEC meson -Db_sanitize=address build $DOCKER_EXEC ninja -v -C build From 86f4edef543d9133a8bc03ff11d1f6ed3cfe4c7a Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Wed, 7 Nov 2018 23:24:16 +0100 Subject: [PATCH 4/8] test: initialize hwdb so that the test won't try to free memory it has never allocated See https://github.com/systemd/systemd/pull/10678#issuecomment-436790906. --- src/test/test-sd-hwdb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/test-sd-hwdb.c b/src/test/test-sd-hwdb.c index b67a8537bf..17ca6a0e27 100644 --- a/src/test/test-sd-hwdb.c +++ b/src/test/test-sd-hwdb.c @@ -5,7 +5,7 @@ #include "tests.h" static int test_failed_enumerate(void) { - _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb; + _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL; const char *key, *value; int r; @@ -29,7 +29,7 @@ static int test_failed_enumerate(void) { "evdev:atkbd:dmi:bvnXXX:bvrYYY:bdZZZ:svnDellXXX:pnYYY" static void test_basic_enumerate(void) { - _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb; + _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL; const char *key, *value; size_t len1 = 0, len2 = 0; int r; From 6dfe7f43d0eb9f2ca0f2d04ba6d04d89de0445b4 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 8 Nov 2018 01:28:11 +0100 Subject: [PATCH 5/8] travis: UBSan should be every C programmer's friend so let's build systemd with it too --- travis-ci/managers/fedora.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/travis-ci/managers/fedora.sh b/travis-ci/managers/fedora.sh index d1ea920a1c..704a3da299 100755 --- a/travis-ci/managers/fedora.sh +++ b/travis-ci/managers/fedora.sh @@ -15,7 +15,7 @@ CONT_NAME="${CONT_NAME:-fedora-$FEDORA_RELEASE-$RANDOM}" DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}" DOCKER_RUN="${DOCKER_RUN:-docker run}" REPO_ROOT="${REPO_ROOT:-$PWD}" -ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan python3-pyparsing python3-evdev) +ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan python3-pyparsing python3-evdev libubsan) function info() { echo -e "\033[33;1m$1\033[0m" @@ -51,9 +51,11 @@ for phase in "${PHASES[@]}"; do ;; RUN_ASAN) $DOCKER_EXEC git clean -dxff - $DOCKER_EXEC meson -Db_sanitize=address build + $DOCKER_EXEC meson -Db_sanitize=address,undefined build $DOCKER_EXEC ninja -v -C build - $DOCKER_EXEC ninja -C build test + + # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb. + $DOCKER_EXEC sh -c "UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 ninja -C build test" ;; CLEANUP) info "Cleanup phase" From 6c8a51ed780b1140b91d4819ddcbbc64632e0b28 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 8 Nov 2018 12:47:07 +0100 Subject: [PATCH 6/8] travis: run ASan job in parallel with the standard one --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index add0576d47..ce5d099660 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,7 @@ jobs: after_script: - $CI_MANAGERS/fedora.sh CLEANUP - - stage: Build & test with ASan - name: Fedora Rawhide + - name: Fedora Rawhide (ASan+UBSan) language: bash env: - FEDORA_RELEASE="rawhide" From 993476841a68b60f0ae8c259939138e1c27409ca Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 8 Nov 2018 13:40:56 +0100 Subject: [PATCH 7/8] travis.yml: replace test-capability with a script exiting with 77 The test is currently failing when run under ASan in a docker container: ``` --- command --- SYSTEMD_KBD_MODEL_MAP='/build/src/locale/kbd-model-map' PATH='/build/build:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' SYSTEMD_LANGUAGE_FALLBACK_MAP='/build/src/locale/language-fallback-map' /build/build/test-capability --- stderr --- have ambient caps: yes Capabilities:= cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read+eip Capabilities:= cap_dac_override,cap_net_raw+ep ==7021==LeakSanitizer has encountered a fatal error. ==7021==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1 ==7021==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc) Assertion 'WIFEXITED(status) && WEXITSTATUS(status) == 0' failed at ../src/test/test-capability.c:71, function fork_test(). Aborting. ------- ``` https://api.travis-ci.org/v3/job/452349948/log.txt --- travis-ci/managers/fedora.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis-ci/managers/fedora.sh b/travis-ci/managers/fedora.sh index 704a3da299..2705e23f8f 100755 --- a/travis-ci/managers/fedora.sh +++ b/travis-ci/managers/fedora.sh @@ -53,6 +53,7 @@ for phase in "${PHASES[@]}"; do $DOCKER_EXEC git clean -dxff $DOCKER_EXEC meson -Db_sanitize=address,undefined build $DOCKER_EXEC ninja -v -C build + $DOCKER_EXEC sh -c "printf '#!/bin/sh\necho The test is failing under ASan, skipping; exit 77' >/build/build/test-capability" # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb. $DOCKER_EXEC sh -c "UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 ninja -C build test" From cdd116b4e1fe3e641e69fe76d69ee0ae3490fede Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 8 Nov 2018 13:45:46 +0100 Subject: [PATCH 8/8] travis: use 3 times the normal timeout when the tests are run under ASan+UBSan --- travis-ci/managers/fedora.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis-ci/managers/fedora.sh b/travis-ci/managers/fedora.sh index 2705e23f8f..742b7c94a4 100755 --- a/travis-ci/managers/fedora.sh +++ b/travis-ci/managers/fedora.sh @@ -56,7 +56,7 @@ for phase in "${PHASES[@]}"; do $DOCKER_EXEC sh -c "printf '#!/bin/sh\necho The test is failing under ASan, skipping; exit 77' >/build/build/test-capability" # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb. - $DOCKER_EXEC sh -c "UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 ninja -C build test" + $DOCKER_EXEC sh -c "UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 meson test --timeout-multiplier=3 -C ./build/ --print-errorlogs" ;; CLEANUP) info "Cleanup phase"