From patchwork Mon Jan 25 15:05:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 87214 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CF4C2A052A; Mon, 25 Jan 2021 16:06:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A82DB140F5D; Mon, 25 Jan 2021 16:06:41 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 24AC6140EFD for ; Mon, 25 Jan 2021 16:06:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611587199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6G/yCgYAg9uk4Y8CMD9LGeT5EcQ+KcdixR4It/LvHL4=; b=KT/zXTD5KH3t4AL8LGQ+1PUw8GUC/+l6VQ5suS9EZk26VdngxYErdMwzOOaW/0HfoDWkke kIBPjBjSQezsq7eEEV+/wyXBR80Pcrv19oKlXelQ0mgQbmTt9qks19T3WgVXbd9TbABztw MLrNFnzeYMXzq4ROKPbeZ7ew+Tv0rcA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-39ZqpD1eNAKOc0KCc6hicQ-1; Mon, 25 Jan 2021 10:06:36 -0500 X-MC-Unique: 39ZqpD1eNAKOc0KCc6hicQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD276100F354; Mon, 25 Jan 2021 15:05:58 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2925660C0F; Mon, 25 Jan 2021 15:05:56 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Aaron Conole , Michael Santana , Olivier Matz Date: Mon, 25 Jan 2021 16:05:39 +0100 Message-Id: <20210125150539.27537-1-david.marchand@redhat.com> In-Reply-To: <20210111100146.3485-1-david.marchand@redhat.com> References: <20210111100146.3485-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2] ci: catch coredumps X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Parts of the unit tests code rely on forked/secondary processes (expectedly) failing. A crash in those situations could be missed so add a check on coredumps presence after unit tests have run. When unit tests fail, it can also help checking for coredumps as it could give more insights on what happened. In some situations (like explicit call to rte_panic), coredump generation must be disabled to avoid false positives. Signed-off-by: David Marchand Acked-by: Luca Boccassi Acked-by: Aaron Conole Acked-by: Luca Boccassi Acked-by: Aaron Conole --- Changelog since RFC v1 - removed RFC, - pushed coredumps into gdb for in-situ analysis, - gdb presence is used to enable the check. Travis config is left untouched for now, --- .ci/linux-build.sh | 37 ++++++++++++++++++++++++++++++++++--- .github/workflows/build.yml | 4 ++++ app/test/test_debug.c | 11 +++++++++-- app/test/test_mbuf.c | 9 ++++++++- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index d2c821adf3..26c30a2301 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -4,7 +4,10 @@ on_error() { if [ $? = 0 ]; then exit fi - FILES_TO_PRINT="build/meson-logs/testlog.txt build/.ninja_log build/meson-logs/meson-log.txt" + FILES_TO_PRINT="build/meson-logs/testlog.txt" + FILES_TO_PRINT="$FILES_TO_PRINT build/.ninja_log" + FILES_TO_PRINT="$FILES_TO_PRINT build/meson-logs/meson-log.txt" + FILES_TO_PRINT="$FILES_TO_PRINT build/gdb.log" for pr_file in $FILES_TO_PRINT; do if [ -e "$pr_file" ]; then @@ -30,6 +33,26 @@ install_libabigail() { rm ${version}.tar.gz } +configure_coredump() { + # No point in configuring coredump without gdb + which gdb >/dev/null || return 0 + ulimit -c unlimited + sudo sysctl -w kernel.core_pattern=/tmp/dpdk-core.%e.%p +} + +catch_coredump() { + ls /tmp/dpdk-core.*.* 2>/dev/null || return 0 + for core in /tmp/dpdk-core.*.*; do + binary=$(sudo readelf -n $core |grep $(pwd)/build/ 2>/dev/null |head -n1) + [ -x $binary ] || binary= + sudo gdb $binary -c $core \ + -ex 'info threads' \ + -ex 'thread apply all bt full' \ + -ex 'quit' + done |tee -a build/gdb.log + return 1 +} + if [ "$AARCH64" = "true" ]; then # convert the arch specifier OPTS="$OPTS --cross-file config/arm/arm64_armv8_linux_gcc" @@ -57,7 +80,11 @@ meson build --werror $OPTS ninja -C build if [ "$AARCH64" != "true" ]; then - devtools/test-null.sh + failed= + configure_coredump + devtools/test-null.sh || failed="true" + catch_coredump + [ "$failed" != "true" ] fi if [ "$ABI_CHECKS" = "true" ]; then @@ -102,5 +129,9 @@ if [ "$ABI_CHECKS" = "true" ]; then fi if [ "$RUN_TESTS" = "true" ]; then - sudo meson test -C build --suite fast-tests -t 3 + failed= + configure_coredump + sudo meson test -C build --suite fast-tests -t 3 || failed="true" + catch_coredump + [ "$failed" != "true" ] fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5b579adda..786525e5a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,6 +104,9 @@ jobs: if: env.AARCH64 == 'true' run: sudo apt install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross pkg-config-aarch64-linux-gnu + - name: Install test tools packages + if: env.AARCH64 != 'true' || env.RUN_TESTS == 'true' + run: sudo apt install -y gdb - name: Install doc generation packages if: env.BUILD_DOCS == 'true' run: sudo apt install -y doxygen graphviz python3-sphinx @@ -124,3 +127,4 @@ jobs: build/meson-logs/testlog.txt build/.ninja_log build/meson-logs/meson-log.txt + build/gdb.log diff --git a/app/test/test_debug.c b/app/test/test_debug.c index 834a7386f5..23b24db177 100644 --- a/app/test/test_debug.c +++ b/app/test/test_debug.c @@ -4,6 +4,8 @@ #include #include +#include +#include #include #include @@ -28,9 +30,14 @@ test_panic(void) pid = fork(); - if (pid == 0) + if (pid == 0) { + struct rlimit rl; + + /* No need to generate a coredump when panicking. */ + rl.rlim_cur = rl.rlim_max = 0; + setrlimit(RLIMIT_CORE, &rl); rte_panic("Test Debug\n"); - else if (pid < 0){ + } else if (pid < 0) { printf("Fork Failed\n"); return -1; } diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index a40f7d4883..47a7b197d7 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -1174,6 +1174,8 @@ test_refcnt_mbuf(void) } #include +#include +#include #include /* use fork() to test mbuf errors panic */ @@ -1186,9 +1188,14 @@ verify_mbuf_check_panics(struct rte_mbuf *buf) pid = fork(); if (pid == 0) { + struct rlimit rl; + + /* No need to generate a coredump when panicking. */ + rl.rlim_cur = rl.rlim_max = 0; + setrlimit(RLIMIT_CORE, &rl); rte_mbuf_sanity_check(buf, 1); /* should panic */ exit(0); /* return normally if it doesn't panic */ - } else if (pid < 0){ + } else if (pid < 0) { printf("Fork Failed\n"); return -1; }