From patchwork Sat Feb 19 11:29:40 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: 12752267 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 52249C433EF for ; Sat, 19 Feb 2022 11:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238581AbiBSLaN (ORCPT ); Sat, 19 Feb 2022 06:30:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232777AbiBSLaJ (ORCPT ); Sat, 19 Feb 2022 06:30:09 -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 E1DAB19FB27 for ; Sat, 19 Feb 2022 03:29:50 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id m27so6924719wrb.4 for ; Sat, 19 Feb 2022 03:29:50 -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=ngmu4/EJFsKCO0dY9NcciwUJjrcXqNDn4Zl/KFJLwM0=; b=bdRHO7qXMHUzYjOjKL3yZZgJZEoEhCSBusk05DualOfXRcQ9im5YzkE/Q1YOg9l/We bAqJ6iV7/mBDTvnXnZhSpnmCJVbzcuQzAPcYt/1MiNFIawu1cDYLjGGBwzfDLtXGOy8Y JmdfuuTJTrp3/IXaNvUKtLWNLaiUDhtvKr4RhIcZNjVWIyUlkwQTfTVDMhB11BLgB81b USe6kPnbgCHzR7Oa1CH3JtPSQeptA94xgCQIQ3CMA3bwB5Z5X5Lw6YE2AYpxADmRsTl0 ojSuhtMGoHjxmiYg7R/HMRlohQOv/LQifKSacp/U8XmLRr+PZSzocfRqbFKYsvgx+s3b tTTg== 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=ngmu4/EJFsKCO0dY9NcciwUJjrcXqNDn4Zl/KFJLwM0=; b=XMmJg0cqXzEapI4i7ErgvOsa2iC4Vgwl+BcWvIXCcvMrJknevNiy0dVwhg9u8NmglH 0PGsus4X+bQYdHVX41GDAJafuURsPp1s56Lzd+7xaw5O0N7VwGGsWYap3fRXE1kXMhAr tnoK3Q8Qs1w3CIfiql6FwQE2rlXf4uFW4dPNTcPdxWNEyRr9xB/IB+KO4qLgkhS2rSsi eFfkO1DfAz/n76b7fFmU2TFhV1uBMOgORrbyaNaY8OOcATY9SIfCQW9c5nYl4ay1DNwQ TSWoTybB7RVxYhN4VojpnA2l8Sjc7kLOJdpmA0SBdn3qWDHAFwadNqBcZn5w66WDqEkX JJRg== X-Gm-Message-State: AOAM5327LHfj3KNsP9iAYiNfxspiMdL2p/EuschNVsYMx/3GXcsheqx7 1hikwfqKbVKfv3eXgh0jwV1vaEqddhuHeQ== X-Google-Smtp-Source: ABdhPJyLjuVqegw50G0v7atUDwsp2FCU04cuD+ybDpg6TIwQ3Aj/L7cSiaE8upqwIwaXrmSvjlqIsQ== X-Received: by 2002:a5d:634b:0:b0:1e3:3226:8e27 with SMTP id b11-20020a5d634b000000b001e332268e27mr8861723wrw.428.1645270189173; Sat, 19 Feb 2022 03:29:49 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id u12sm29464695wrw.32.2022.02.19.03.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 03:29:48 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 1/4] test-lib: add GIT_XSAN_OPTIONS, inherit [AL]SAN_OPTIONS Date: Sat, 19 Feb 2022 12:29:40 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1130.g7c6dd716f26 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 do want to take any user-provided settings over our own, but we can do 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..7e6978d1817 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_XSAN_OPTIONS variable can be used to set common +# defaults shared between [AL]SAN_OPTIONS. +prepend_var GIT_XSAN_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_XSAN_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_XSAN_OPTIONS export LSAN_OPTIONS if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS From patchwork Sat Feb 19 11:29:41 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: 12752269 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 18D4EC433EF for ; Sat, 19 Feb 2022 11:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238937AbiBSLaO (ORCPT ); Sat, 19 Feb 2022 06:30:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234506AbiBSLaK (ORCPT ); Sat, 19 Feb 2022 06:30:10 -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 E7DC51A02AE for ; Sat, 19 Feb 2022 03:29:51 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id bg21-20020a05600c3c9500b0035283e7a012so8174160wmb.0 for ; Sat, 19 Feb 2022 03:29:51 -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=Ueff2Pq3FW2KU6iRzhdf2X/rkE2dXkoqozgMf7IjS+U=; b=PG2MDxew9cOvg4kJgizptPfeBAaKf2OioKFcV9jpoUp8KM4ug3AZyepX5LcISs7JYb 5zmB+wMc4tGK62ZD+g+ju/GlhpPBwzGa5BCV2cQ7MHR9DccIhjFiViYNzwqb24oY3E37 dRJp4oL+Yzd6m5jQBJsskj8CZKwQ+zzYacjRfdyixrEzHVjWkTvSr5S/OZ87YJifwaea 25Q+Y7X1LCne9gFlkWfmAIjlNwbPyDvdRPlqs8CLHlhPorBR9YtWmzCyAqoEubF2qau4 dUVKIedR5bZfbGfhA8sOf+fph06UrieKJWCi0ERPVJBt3mT/L7Hv8nZAUXPAG2dp4Ar+ YPbQ== 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=Ueff2Pq3FW2KU6iRzhdf2X/rkE2dXkoqozgMf7IjS+U=; b=mL5cNPV51GpRfzrakxCh0Mk1ulQPvBG8ZYWY9F5uZuMSW9WixTIRfjub77x+BZViMk TrxxXz7ulA6uy4nlHqJsbIC008v0eAV6l9OXId84L8HospEZArJtWpreLGFQRuTBnXKI +Ng2QskTJRL+T6sL7mmO23c1nQ5+TTEjx1gqvIYPvXIV1j5heDhRub9KeI2snuWElaL6 sZ8/xOm3PxFd+j8tTBLOjdg2dD7WI4KMKG0uaBxjPyULvuNo3IHTobpTj/Vv8wuYgAdx RAxEBFc1MiLYWi03YmPIjUqm3Tq5fRuRkYTTbf1FPDrEREcJpAIOrQTnOh4N5LLA7y5E p6MQ== X-Gm-Message-State: AOAM531VXiC4YsVpFF2E/Qwfw/PuGGPy/QWqkqVH4EViquXfmvVrAejz X1GxoLXXToN4QpHP9zufqlaZgBjefMaxuw== X-Google-Smtp-Source: ABdhPJxNQ/1zxmhVYBEKYOAGXgsV/qJRfiITV8MpjfvKPKkS/cynHlWWr8R+Kzq35rT4XHDMnoIwRA== X-Received: by 2002:a05:600c:646:b0:37b:b738:f52c with SMTP id p6-20020a05600c064600b0037bb738f52cmr14377981wmm.30.1645270189977; Sat, 19 Feb 2022 03:29:49 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id u12sm29464695wrw.32.2022.02.19.03.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 03:29:49 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 2/4] test-lib: correct commentary on TEST_DIRECTORY overriding Date: Sat, 19 Feb 2022 12:29:41 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1130.g7c6dd716f26 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 7e6978d1817..8fa7379e128 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 Sat Feb 19 11:29:42 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: 12752270 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 2F028C433F5 for ; Sat, 19 Feb 2022 11:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239086AbiBSLaQ (ORCPT ); Sat, 19 Feb 2022 06:30:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238166AbiBSLaL (ORCPT ); Sat, 19 Feb 2022 06:30:11 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E94F719FACE for ; Sat, 19 Feb 2022 03:29:52 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id d27so18722293wrc.6 for ; Sat, 19 Feb 2022 03:29:52 -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=xr5cUOOop8mkApvxYgbKosQT5yy1LRTRWCI28T/PzHc=; b=FjS+Rq/ZhFRveapqMmgNzr3cJmL7inVu7PSCBQAXsiZeYu2z8RLQqZCJd+1gNCnqzU +Egfg/fEepOY9IrCZdq5r93SPBmND5QmOerF9yx1QNefNwhWtGFpfnAzpT1G4OtryRSJ 2FTGRPRq5N+1YMyhmyhfrfOVzJMF2RiWlYe+/Vocv8tufOw//nA7oUdH3+uclp4nHj4u 3Pj6SYCXmFWEJa0g80/cJJdCi6b21xlhydG+mLvbMf3GtaI4uzt/IZqjtARw76sJHEqL tdAbN+rAhosPbA1D2fadFL4zlXCxFyQMg2pi4T8PeMjnqjiVXHY1EsI/fB1zD6JWGKxT dWlg== 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=xr5cUOOop8mkApvxYgbKosQT5yy1LRTRWCI28T/PzHc=; b=oUQJG2DkE2I02KjW+d5d5W91F/zy1Ql7Y0GHkmYQw/0AHbf7eUsHst0PdhzA0I5SEm liY6KT9Ku3fbxk16+b0inWgSMB9F9WiwqRA6+jMtXPorL6XVTE9ZLTNQTh/pJv/Wv0Kv /PuyT4VaN5vZROxfGwzMmwJ2VdQeUyPqWtbk3suMChJ/snoRcdOpw8KWfrUvuUHaxNn2 kewcSDLfxrAldI3GgHGwD3bBbio+Oo21IVGcH+EgTT5pPUY5vqHgwhV6O7jXN8jAa01W VID+MYBKYvDZgIUJ89Wy+o+sgH1FQFIku9K9Q4qaojGqKREI3rUGZdFOapQlpaVQwqJp wYzg== X-Gm-Message-State: AOAM533YUn2CVUgQUr/jS2KgiVnAt/kkChmdtam+c9wn8laSpTZehceH Oma4U8XVgYiOGsUhoUoBE9IQuzvIDqR+QQ== X-Google-Smtp-Source: ABdhPJy/nYiDJ+mpHMIOvgO3RKJEE9DuTyP4Y4pqY3GZO1QieVTeOnQnP8LHK9ZEDW5wGEUNUP98DQ== X-Received: by 2002:adf:f6c3:0:b0:1e4:9b8f:8f72 with SMTP id y3-20020adff6c3000000b001e49b8f8f72mr9111446wrp.287.1645270191239; Sat, 19 Feb 2022 03:29:51 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id u12sm29464695wrw.32.2022.02.19.03.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 03:29:50 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 3/4] test-lib: make $GIT_BUILD_DIR an absolute path Date: Sat, 19 Feb 2022 12:29:42 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1130.g7c6dd716f26 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 8fa7379e128..80944035f2c 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_XSAN_OPTIONS variable can be used to set common # defaults shared between [AL]SAN_OPTIONS. prepend_var GIT_XSAN_OPTIONS : abort_on_error=1 +prepend_var GIT_XSAN_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 Sat Feb 19 11:29:43 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: 12752271 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 47E0CC433EF for ; Sat, 19 Feb 2022 11:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240110AbiBSLaW (ORCPT ); Sat, 19 Feb 2022 06:30:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238736AbiBSLaN (ORCPT ); Sat, 19 Feb 2022 06:30:13 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5BAC1A138D for ; Sat, 19 Feb 2022 03:29:53 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id k41so6777252wms.0 for ; Sat, 19 Feb 2022 03:29:53 -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=vcmhDwstsnXq2UShK2IxmKIdoFf3vKkUu53WK6LSagA=; b=M4OzqJ69xr+8ojhBPfnpalSgqLiS5yqwmSpxUIjwuj884RQmJgfTLrbm/YgVRMJ77M VFOIpPYDgbJFO1P/zOGZgqe+7cqXnpWm/B1rucuyJra0WBQy9TMLyx2ak055nnL/SILH N1TLirPfGN/+c4TAqrgQt+rzSkCF6MC0QsqDzT5u6jEyA8673AJ/vmxJaoCUVgzJ258+ A6FeGJ3A5s463zUiyOXYtnlVZ7sgJlKw1PBBWX/VtB/IFJUD3Q7UHqqvux0jgja3Vej3 OIqEwUwt9N/h6f22FyxkUdY9bSKNDklSkFnH7B7+SZv617GSoxJFVxglTOKN3Oi/E7NL vaAA== 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=vcmhDwstsnXq2UShK2IxmKIdoFf3vKkUu53WK6LSagA=; b=OKKa9Do4d+rI7jC5X6PXAnryqKoB2EuV12BBGRKYAba+yEFZ+Y6ZaCvuu/iC6mYVgK nIaUgj9AKI/JKik7C3K2kSKgz0duaOEmRu/lkqdqJ+RgC28XL4F/WCQNN2XoVVADwP3+ c1f8pgg+tDTtlTXJX5dkrNvKDbBDFz5F0KSlQa4VDiTBFJxghRsUon1M276rMa7+FHyO S/ZHZegQFe+BFNmJTsUGvdLkeCW7Nx1l2hRi7JKUvaANPl4NTL3VMBxnSiImPDghxcn0 VgT2eZphDFba4KwiTeHUW4LzIbz37u/Qnx9Cg3d3T4ZlV3o6uJCsBS03/y+6vW5yG/jX 8oWA== X-Gm-Message-State: AOAM533/Gzp9lHSOdeyOjqw2ZIPV8K2hD/I4naactPFx6VTeTe79RxSQ T7LPrUKhI3jeKTIAtZS0RQqYlVTjwBTwYw== X-Google-Smtp-Source: ABdhPJxOwgooUKFX3Nlnndia15WLqBUiTFIniCzUElWTbct4WmdTaa/X6yEZ69jVv64AqK66OJ32lQ== X-Received: by 2002:a1c:4d0e:0:b0:37c:b85:5404 with SMTP id o14-20020a1c4d0e000000b0037c0b855404mr10366384wmh.184.1645270192156; Sat, 19 Feb 2022 03:29:52 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id u12sm29464695wrw.32.2022.02.19.03.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 03:29:51 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 4/4] test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONS Date: Sat, 19 Feb 2022 12:29:43 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1130.g7c6dd716f26 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 80944035f2c..129668c685f 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_XSAN_OPTIONS +prepend_var LSAN_OPTIONS : fast_unwind_on_malloc=0 export LSAN_OPTIONS if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS