From patchwork Mon Feb 21 15:58:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12753838 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7E35C433F5 for ; Mon, 21 Feb 2022 15:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379774AbiBUP7X (ORCPT ); Mon, 21 Feb 2022 10:59:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235763AbiBUP7W (ORCPT ); Mon, 21 Feb 2022 10:59:22 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB772980C for ; Mon, 21 Feb 2022 07:58:58 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id az26-20020a05600c601a00b0037c078db59cso11491755wmb.4 for ; Mon, 21 Feb 2022 07:58:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ObOtvIQLn55nvRiRlYVIDva0R11X8Tr96pfZoGcXu5Q=; b=M/dbs/LsfIEYOnJyCWJ8myVsylp2DQ5Qe1gMi9xFZ94qCeTnh0Lc3PWoEi/yNN/Sb9 ulDEjyAre3oHJXj62o1fd9Y/uTr+efOutWaKnhOfVO3VW39T+2v0zjFOQw4yz+F26MWO 6S9aW7JEfRGLpERcLUteguELqagWFKXyBWgiDmvaQrQ01H5DHnqFTgu7SpUfs+s1vCSK ZuY79RKp5O30FBJDSNItPXKUWfNyEXTPbLgP/Lb/Y3ua3+2wmVs0daFq510BJ0gBD03z gdYWQDcZ1ZA3FN2TqC9VzU53NjICxQksCsaC9JveFlT5nrNErezUr4rD1BmXo6Fn6Us3 wRig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ObOtvIQLn55nvRiRlYVIDva0R11X8Tr96pfZoGcXu5Q=; b=p1VZ9kpmZioop2QtBWYFM1FO92W/oHZUCC1PVmrdA96nN4Eg+dDSL8IrBS1zg2EyLS KboThJg330xn8+JKeJIPo/z1F9f9V3zb/l7OEo7hyynz5PHEAnoK0WWvg85ITF12vlt5 1WywUxqq67Fpq+IqjLucp+1TDTYjAPq7Nk3wNJ//QOkrCaNWz5ImTG7h4BK5GuomWP3g 8M87EDPtJqRfz7woJCafjWs1DQYmz4IDqFeQaFgf34PYnj9nHZu+8cO+rexlKvtohhVy MOBLOll8ozOyblRvsxujhOKBI/QcKQei4mugLy0UQjvut6sHRj+qPVslrEmUEcCppM12 Y2WA== X-Gm-Message-State: AOAM530eNByayimS7SXS7dU/nZC/pGdt3DCDQtU1d4/BxdlBRl4uRMGU G9M76vwYSsdaE0w0IZaX4k4nPlguRE4okg== X-Google-Smtp-Source: ABdhPJy3uoYeUxkes3Scv9W/UzQnfP5fG4eRffLLoQps5TngilvECUEwAKnN1qf0k/CAIvJNUgePMA== X-Received: by 2002:a05:600c:1ca1:b0:37b:a639:96a5 with SMTP id k33-20020a05600c1ca100b0037ba63996a5mr21715492wms.68.1645459136802; Mon, 21 Feb 2022 07:58:56 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id x10sm7811170wmj.17.2022.02.21.07.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 07:58:55 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 1/4] test-lib: add GIT_SAN_OPTIONS, inherit [AL]SAN_OPTIONS Date: Mon, 21 Feb 2022 16:58:32 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1132.ga1fe46f8690 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change our ASAN_OPTIONS and LSAN_OPTIONS to set defaults for those variables, rather than punting out entirely if we already have them in the environment. We want to take any user-provided settings over our own, but we can do that by prepending our defaults to the variable. The libsanitizer options parsing has "last option wins" semantics. It's now possible to do e.g.: LSAN_OPTIONS=report_objects=1 ./t0006-date.sh And not have the "report_objects=1" setting overwrite our sensible default of "abort_on_error=1", but by prepending to the list we ensure that: LSAN_OPTIONS=report_objects=1:abort_on_error=0 ./t0006-date.sh Will take the desired "abort_on_error=0" over our default. See b0f4c9087e1 (t: support clang/gcc AddressSanitizer, 2014-12-08) for the original pattern being altered here, and 85b81b35ff9 (test-lib: set LSAN_OPTIONS to abort by default, 2017-09-05) for when LSAN_OPTIONS was added in addition to the then-existing ASAN_OPTIONS. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index e4716b0b867..55f263a02d3 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -36,17 +36,33 @@ then fi GIT_BUILD_DIR="$TEST_DIRECTORY"/.. +# Prepend a string to a VAR using an arbitrary ":" delimiter, not +# adding the delimiter if VAR or VALUE is empty. I.e. a generalized: +# +# VAR=$1${VAR:+${1:+$2}$VAR} +# +# Usage (using ":" as the $2 delimiter): +# +# prepend_var VAR : VALUE +prepend_var () { + eval "$1=$3\${$1:+${3:+$2}\$$1}" +} + +# If [AL]SAN is in effect we want to abort so that we notice +# problems. The GIT_SAN_OPTIONS variable can be used to set common +# defaults shared between [AL]SAN_OPTIONS. +prepend_var GIT_SAN_OPTIONS : abort_on_error=1 + # If we were built with ASAN, it may complain about leaks # of program-lifetime variables. Disable it by default to lower # the noise level. This needs to happen at the start of the script, # before we even do our "did we build git yet" check (since we don't # want that one to complain to stderr). -: ${ASAN_OPTIONS=detect_leaks=0:abort_on_error=1} +prepend_var ASAN_OPTIONS : $GIT_SAN_OPTIONS +prepend_var ASAN_OPTIONS : detect_leaks=0 export ASAN_OPTIONS -# If LSAN is in effect we _do_ want leak checking, but we still -# want to abort so that we notice the problems. -: ${LSAN_OPTIONS=abort_on_error=1} +prepend_var LSAN_OPTIONS : $GIT_SAN_OPTIONS export LSAN_OPTIONS if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS From patchwork Mon Feb 21 15:58:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12753840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92335C433F5 for ; Mon, 21 Feb 2022 15:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379780AbiBUP70 (ORCPT ); Mon, 21 Feb 2022 10:59:26 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379772AbiBUP7X (ORCPT ); Mon, 21 Feb 2022 10:59:23 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 771052981E for ; Mon, 21 Feb 2022 07:58:59 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id d28so117596wra.4 for ; Mon, 21 Feb 2022 07:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IXFwM9kiNqOUcDYCHCf1XEO6M6OQmwEXQh1cg5pCg0A=; b=YOprWm0M5e+5bh6+FFzzFq0Xt4wd6lZ6YustpYfdsBYoetCVen+DRlui/bWOXGA0FP gh1ApGnh7zVY1qaU4799T6oTIWEfL3+8jIP5xgwfA12cwjC9SsSmuQ+sezm5P3dEK7wk JMGcoyqMr8ECzfowCS1GeeI3QraeGpUd/vtTP13i+gtm1/+vHyrJ8LTP9AUyZIxtIyAN RNMRJ9dd+xn+obyeXWZgFhUAaiM9su7Vcc12/cfS6eZrXru6E6ACF/5BMe7ysD7i8Kv9 nOO30LTWBWGottOLIZdwgm2LrOYnPXKXn8ASAWGFF0c2GH8pPlcl12gyyXeYkUP9nOpS ldWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IXFwM9kiNqOUcDYCHCf1XEO6M6OQmwEXQh1cg5pCg0A=; b=1Vd6RDvaYIIf35foIwx13qVSC9lW7CQ8mtdyl8QcU+NIgdLmavK+U1J06yIbYIK8fi yF31kHAtIvWd0O9hrozgvdp6+C54brNBz4ARMPb8oMSLjw6gUHe8IlzJRGtCgZhqSUyF iDhl4V3NKobSKAkd9wiSNCTwQ20N8at213TqDmzh4FMWGP1w+eX4lKd3wV9WfZM7GGwV zOHTngKYkbZb1jKCSNvzuYg7k4WiCKn4GK0rqdOYLvDg0WuU7i5tsO6rVYqCnEH2a/BT 7EbT8tjsP8wQiuMX1MjXL0xuw6LERX/+Y0Ps+4QgHlmj0UiuIf5FP4gt6XKR10RMAoF6 wRxQ== X-Gm-Message-State: AOAM532yTgvig8FVdFCBJ/5EbvuKKgx3Z2/f4FMGxE6QiyjPTGtv/cgc 4XXrXGeBjwun8dJdxLKEZ8to/mKN9H096A== X-Google-Smtp-Source: ABdhPJx5M7fIZgSih/xHRtxRmGmrNO9i75dKAUjZCuPSVrljPF+p7aU47AEGoWXH9Yj7zbnX8Dn24Q== X-Received: by 2002:adf:f7cc:0:b0:1e4:b2d4:f432 with SMTP id a12-20020adff7cc000000b001e4b2d4f432mr16661182wrq.430.1645459137807; Mon, 21 Feb 2022 07:58:57 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id x10sm7811170wmj.17.2022.02.21.07.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 07:58:57 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 2/4] test-lib: correct commentary on TEST_DIRECTORY overriding Date: Mon, 21 Feb 2022 16:58:33 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1132.ga1fe46f8690 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Correct a misleading comment added by me in 62f539043c7 (test-lib: Allow overriding of TEST_DIRECTORY, 2010-08-19). Between that comment and the later addition of 85176d72513 (test-lib.sh: convert $TEST_DIRECTORY to an absolute path, 2013-11-17) the comments were on the wrong arms of the "if". I.e. the "allow tests to override this" was on the "test -z" arm. But more importantly this could be read allowing the "$TEST_DIRECTORY" to be some path outside of t/. As explained in the updated comment that's impossible, rather it was meant for *tests* that ran outside of t/, i.e. the "t0000-basic.sh" tests that use "lib-subtest.sh". Those tests have a different working directory, but they set the "TEST_DIRECTORY" to the same path for bootstrapping. The comments now reflect that, and further comment on why we have a hard dependency on this. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 55f263a02d3..77c3fabd041 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -19,13 +19,20 @@ # t/ subdirectory and are run in 'trash directory' subdirectory. if test -z "$TEST_DIRECTORY" then - # We allow tests to override this, in case they want to run tests - # outside of t/, e.g. for running tests on the test library - # itself. - TEST_DIRECTORY=$(pwd) -else # ensure that TEST_DIRECTORY is an absolute path so that it # is valid even if the current working directory is changed + TEST_DIRECTORY=$(pwd) +else + # The TEST_DIRECTORY will always be the path to the "t" + # directory in the git.git checkout. This is overridden by + # e.g. t/lib-subtest.sh, but only because its $(pwd) is + # different. Those tests still set "$TEST_DIRECTORY" to the + # same path. + # + # See use of "$GIT_BUILD_DIR" and "$TEST_DIRECTORY" below for + # hard assumptions about "$GIT_BUILD_DIR/t" existing and being + # the "$TEST_DIRECTORY", and e.g. "$TEST_DIRECTORY/helper" + # needing to exist. TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1 fi if test -z "$TEST_OUTPUT_DIRECTORY" From patchwork Mon Feb 21 15:58:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12753841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4FD9C433EF for ; Mon, 21 Feb 2022 15:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379782AbiBUP71 (ORCPT ); Mon, 21 Feb 2022 10:59:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235763AbiBUP7X (ORCPT ); Mon, 21 Feb 2022 10:59:23 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98D222980C for ; Mon, 21 Feb 2022 07:59:00 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id k127-20020a1ca185000000b0037bc4be8713so13854866wme.3 for ; Mon, 21 Feb 2022 07:59:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jfCQMduVXvjJ2AVTzh9g/J8jvzCk9kASlQMKD3rn+dY=; b=diNMfGwJAfxetiNpFY7Luo549Eg+Ob0n2HvZ4YIgFzziGy+69RYS8AbhkB6UEzq15p Rv8Ik4aBIAQS6c7gm5C+kOz6mSAkdpE/ugHEykO3ifEDDElLSDCxrhE8/sASmzKQNIct 1VrcrM5EYJQsdAF98PTaOfZs+gpE6UHREX9PRdtbyVmEiZzOdLJdTCC/qI7jLRmwD7Wv QuaxEPuRtW1dPNS0iFJtfA4vAB/s2Lj6fN2cWBhqLJ89MdbaUtNa9lMSzyzHDdBuRLqM /xWdnbG2TkSmJxYcf/oQDpxfsgb+vuYmPjz1AA98WPgYjLLz7bwA/He2tKOAC5YrxWFS snaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jfCQMduVXvjJ2AVTzh9g/J8jvzCk9kASlQMKD3rn+dY=; b=kq2XCFxKO4l2P0SUn8pxfuB5gWIj7bwwkGJ1NJ/LH+Xe21e+En6WCNZX6zinquGqW2 3SAEtZlh9EoodUodhS1cCnZ5XQ6MMYe4NJynbmkHvRx/wmW5cmEpZSEWLAezGKjOC+vk SGyIdJBg3HWnNLQ8T5J2xD08iwplKGmhhhx5xKlWXwtWRHGHddFbpa7CWXX1CDwgGVde AeKTH07tS9pMRd5KGY1B8yyheZx1TwuTll5HOZ8ldLNjER6LN9rP3O+Vf3DeeqJvw7Ii uivigCe4EhrsvvgKJDIeCdlyRm7f1obNWvk1ljcQ1cfTSJnwOEI0itQCnURujj6tzOeF RV1Q== X-Gm-Message-State: AOAM533vWBgAlznzUOTCzOUHFsPPTZMIdEQ2HZitIYoulm4pXBmociQA Tvoq/+TOzGL8a2h+gOVfwugt0HCvtJEl3Q== X-Google-Smtp-Source: ABdhPJzAGAXiEiETSLRjnv+otB9nHtXkwAi+iZW7vHhMZ7H4XJUsmEpSv9tTncovK6lCoAsj0+hTEA== X-Received: by 2002:a7b:ce83:0:b0:37b:f1f1:3a0c with SMTP id q3-20020a7bce83000000b0037bf1f13a0cmr18097755wmj.10.1645459138800; Mon, 21 Feb 2022 07:58:58 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id x10sm7811170wmj.17.2022.02.21.07.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 07:58:58 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 3/4] test-lib: make $GIT_BUILD_DIR an absolute path Date: Mon, 21 Feb 2022 16:58:34 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1132.ga1fe46f8690 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the GIT_BUILD_DIR from a path like "/path/to/build/t/.." to "/path/to/build". The "TEST_DIRECTORY" here is already made an absolute path a few lines above this. We could simply do $(cd "$TEST_DIRECTORY"/.." && pwd) here, but as noted in the preceding commit the "$TEST_DIRECTORY" can't be anything except the path containing this test-lib.sh file at this point, so we can more cheaply and equally strip the "/t" off the end. This change will be helpful to LSAN_OPTIONS which will want to strip the build directory path from filenames, which we couldn't do if we had a "/.." in there. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 77c3fabd041..ff13321bfd3 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -41,7 +41,7 @@ then # elsewhere TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY fi -GIT_BUILD_DIR="$TEST_DIRECTORY"/.. +GIT_BUILD_DIR="${TEST_DIRECTORY%/t}" # Prepend a string to a VAR using an arbitrary ":" delimiter, not # adding the delimiter if VAR or VALUE is empty. I.e. a generalized: @@ -59,6 +59,7 @@ prepend_var () { # problems. The GIT_SAN_OPTIONS variable can be used to set common # defaults shared between [AL]SAN_OPTIONS. prepend_var GIT_SAN_OPTIONS : abort_on_error=1 +prepend_var GIT_SAN_OPTIONS : strip_path_prefix=\"$GIT_BUILD_DIR/\" # If we were built with ASAN, it may complain about leaks # of program-lifetime variables. Disable it by default to lower From patchwork Mon Feb 21 15:58:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12753842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872C2C433EF for ; Mon, 21 Feb 2022 15:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346428AbiBUP7e (ORCPT ); Mon, 21 Feb 2022 10:59:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379778AbiBUP7Z (ORCPT ); Mon, 21 Feb 2022 10:59:25 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A983429817 for ; Mon, 21 Feb 2022 07:59:01 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id o24so27909949wro.3 for ; Mon, 21 Feb 2022 07:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eLUJL2mxz2y+4aBg9VQWVZGxIn/Fmqqg98RnoffVUrA=; b=I72NDD9YjkaXG7HsgsCp94BMk/a1v6coXHUytmYOcEeFEarD7W0IKOxFhBZFmHTl5x SGulBfjfO1FgT7s8POkEZ6mhtLh7Kye5aodyNL3K2niN0zj6OnUIq5K+haAaeYdUi3p+ FCsCzToe2EUnYn2tbeb0BUfD0jXCXUVtxlwttvESrxTIKBqWV2d/frbKXbxWPx8kPdsX p12oC2VEg0mvNFIkLlVdlHQlSZGDUTG/bJr8WNZ8fJuHN7Nr6giJ+0hoswmM74IiB8RX eGy+XawarPRCowle+zMBbEbaCqW2B2pJW2/l38d9JqT+kbknFsFG1LiwDhVfqVqtAjOR OykA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eLUJL2mxz2y+4aBg9VQWVZGxIn/Fmqqg98RnoffVUrA=; b=cvUvPl/VC9LdMwAh9pFPgL9niNyg1e8djYA/RbWQLpTXvDVKtSNpIl6NlpnOGoxrY6 //x6zbRJYyAyVXOl/i6pE9QbSIq5Z9WV7B9j5qDHjxWw18v5x4jaIX+qmsi3k1QOIl+R yvpkQu1CNf3Dx/nyAsbAk8CRPlgkKCqYNrIr3KQ+MQTp6mDaksRpCdEd7SBFuRf9B4LF o0hQEwBNFCLOo+uejJYUh5MBsH8M2Jw1ba2R8Tlfk+W2Lmy7SqTStTJ6Hr35zKFJg5KL a53E8P7diUM1apLSntBGdaNog9uhlIV7YtVehZP89wVh2LldWlbh7vV0J/GYsHd7C5BP MmEg== X-Gm-Message-State: AOAM530YsoG2eePXddmrNEpGN3t+PJTJhnggON787bXI4BcTReT/IzXb cDPinY4mr30euD2I/24LvSEEYVrbU26qqQ== X-Google-Smtp-Source: ABdhPJysRlUDoHyFJC+ModDFWop1OcHRMsEOoSz3vTKEkGw2fXfVcsiV3O7y3g6Hwyu8mU9QI+U6AQ== X-Received: by 2002:adf:e646:0:b0:1e4:a4b1:6cdf with SMTP id b6-20020adfe646000000b001e4a4b16cdfmr16439021wrn.205.1645459139915; Mon, 21 Feb 2022 07:58:59 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id x10sm7811170wmj.17.2022.02.21.07.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 07:58:59 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 4/4] test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONS Date: Mon, 21 Feb 2022 16:58:35 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1132.ga1fe46f8690 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add "fast_unwind_on_malloc=0" to LSAN_OPTIONS to get more meaningful stack traces from LSAN. This isn't required under ASAN which will emit traces such as this one for a leak in "t/t0006-date.sh": $ ASAN_OPTIONS=detect_leaks=1 ./t0006-date.sh -vixd [...] Direct leak of 3 byte(s) in 1 object(s) allocated from: #0 0x488b94 in strdup (t/helper/test-tool+0x488b94) #1 0x9444a4 in xstrdup wrapper.c:29:14 #2 0x5995fa in parse_date_format date.c:991:24 #3 0x4d2056 in show_dates t/helper/test-date.c:39:2 #4 0x4d174a in cmd__date t/helper/test-date.c:116:3 #5 0x4cce89 in cmd_main t/helper/test-tool.c:127:11 #6 0x4cd1e3 in main common-main.c:52:11 #7 0x7fef3c695e49 in __libc_start_main csu/../csu/libc-start.c:314:16 #8 0x422b09 in _start (t/helper/test-tool+0x422b09) SUMMARY: AddressSanitizer: 3 byte(s) leaked in 1 allocation(s). Aborted Whereas LSAN would emit this instead: $ ./t0006-date.sh -vixd [...] Direct leak of 3 byte(s) in 1 object(s) allocated from: #0 0x4323b8 in malloc (t/helper/test-tool+0x4323b8) #1 0x7f2be1d614aa in strdup string/strdup.c:42:15 SUMMARY: LeakSanitizer: 3 byte(s) leaked in 1 allocation(s). Aborted Now we'll instead git this sensible stack trace under LSAN. I.e. almost the same one (but starting with "malloc", as is usual for LSAN) as under ASAN: Direct leak of 3 byte(s) in 1 object(s) allocated from: #0 0x4323b8 in malloc (t/helper/test-tool+0x4323b8) #1 0x7f012af5c4aa in strdup string/strdup.c:42:15 #2 0x5cb164 in xstrdup wrapper.c:29:14 #3 0x495ee9 in parse_date_format date.c:991:24 #4 0x453aac in show_dates t/helper/test-date.c:39:2 #5 0x453782 in cmd__date t/helper/test-date.c:116:3 #6 0x451d95 in cmd_main t/helper/test-tool.c:127:11 #7 0x451f1e in main common-main.c:52:11 #8 0x7f012aef5e49 in __libc_start_main csu/../csu/libc-start.c:314:16 #9 0x42e0a9 in _start (t/helper/test-tool+0x42e0a9) SUMMARY: LeakSanitizer: 3 byte(s) leaked in 1 allocation(s). Aborted As the option name suggests this does make things slower, e.g. for t0001-init.sh we're around 10% slower: $ hyperfine -L v 0,1 'LSAN_OPTIONS=fast_unwind_on_malloc={v} make T=t0001-init.sh' -r 3 Benchmark 1: LSAN_OPTIONS=fast_unwind_on_malloc=0 make T=t0001-init.sh Time (mean ± σ): 2.135 s ± 0.015 s [User: 1.951 s, System: 0.554 s] Range (min … max): 2.122 s … 2.152 s 3 runs Benchmark 2: LSAN_OPTIONS=fast_unwind_on_malloc=1 make T=t0001-init.sh Time (mean ± σ): 1.981 s ± 0.055 s [User: 1.769 s, System: 0.488 s] Range (min … max): 1.941 s … 2.044 s 3 runs Summary 'LSAN_OPTIONS=fast_unwind_on_malloc=1 make T=t0001-init.sh' ran 1.08 ± 0.03 times faster than 'LSAN_OPTIONS=fast_unwind_on_malloc=0 make T=t0001-init.sh' I think that's more than worth it to get the more meaningful stack traces, we can always provide LSAN_OPTIONS=fast_unwind_on_malloc=0 for one-off "fast" runs. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/test-lib.sh b/t/test-lib.sh index ff13321bfd3..a96d19a332e 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -71,6 +71,7 @@ prepend_var ASAN_OPTIONS : detect_leaks=0 export ASAN_OPTIONS prepend_var LSAN_OPTIONS : $GIT_SAN_OPTIONS +prepend_var LSAN_OPTIONS : fast_unwind_on_malloc=0 export LSAN_OPTIONS if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS