git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/4] test-lib: improve LSAN + ASAN stack traces

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 19, 2022, 11:29 UTC
Message-ID
<cover-v2-0.4-00000000000-20220219T112653Z-avarab@gmail.com>
In-Reply-To
<cover-0.4-00000000000-20220218T205753Z-avarab@gmail.com>

A UX improvement for LSAN stack traces. See https://lore.kernel.org/git/cover-0.4-00000000000-20220218T205753Z-avarab@gmail.com/ for the v1.

I think this v2 should address all the comments on the v1, thanks Taylor & Junio!

Changes:
 * Renamed XSAN_OPTIONS to GIT_XSAN_OPTIONS
 * The "prepend_var" now handles an empty $3, as suggested by Junio.
 * I added a new 2/4 updating the $TEST_DIRECTORY commentary to note
   that we depend on it pointing to *the* "t" directory.
Ævar Arnfjörð Bjarmason (4):
  test-lib: add GIT_XSAN_OPTIONS, inherit [AL]SAN_OPTIONS
  test-lib: correct commentary on TEST_DIRECTORY overriding
  test-lib: make $GIT_BUILD_DIR an absolute path
  test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONS
 t/test-lib.sh | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)
Range-diff against v1:
1:  75c8f7a719c ! 1:  01e63a72231 test-lib: add XSAN_OPTIONS, inherit [AL]SAN_OPTIONS
    @@ Metadata
     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## Commit message ##
    -    test-lib: add XSAN_OPTIONS, inherit [AL]SAN_OPTIONS
    +    test-lib: add GIT_XSAN_OPTIONS, inherit [AL]SAN_OPTIONS
     
         Change our ASAN_OPTIONS and LSAN_OPTIONS to set defaults for those
         variables, rather than punting out entirely if we already have them in
    @@ t/test-lib.sh: then
      GIT_BUILD_DIR="$TEST_DIRECTORY"/..
      
     +# Prepend a string to a VAR using an arbitrary ":" delimiter, not
    -+# adding the delimiter if VAR is empty. I.e. a generalized:
    ++# adding the delimiter if VAR or VALUE is empty. I.e. a generalized:
     +#
    -+#	VAR=$1${VAR:+$VAR}
    ++#	VAR=$1${VAR:+${1:+$2}$VAR}
     +#
    -+# Usage (using ":" as a delimiter):
    ++# Usage (using ":" as the $2 delimiter):
     +#
    -+#	prepend_var VAR : $1
    ++#	prepend_var VAR : VALUE
     +prepend_var () {
    -+	eval "$1=$3\${$1:+$2\$$1}"
    ++	eval "$1=$3\${$1:+${3:+$2}\$$1}"
     +}
     +
    -+# If [AL]SAN is in effect we want to abort so that we notice problems.
    -+prepend_var XSAN_OPTIONS : abort_on_error=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
    @@ t/test-lib.sh: then
      # 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 : $XSAN_OPTIONS
    ++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 : $XSAN_OPTIONS
    ++prepend_var LSAN_OPTIONS : $GIT_XSAN_OPTIONS
      export LSAN_OPTIONS
      
      if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
-:  ----------- > 2:  0c2867e30dc test-lib: correct commentary on TEST_DIRECTORY overriding
2:  4c53c6157ac ! 3:  229654027b8 test-lib: make $GIT_BUILD_DIR an absolute path
    @@ Commit message
         "/path/to/build". The "TEST_DIRECTORY" here is already made an
         absolute path a few lines above this.
     
    -    This 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.
    +    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 <avarab@gmail.com>
     
    @@ t/test-lib.sh: then
     +GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
      
      # Prepend a string to a VAR using an arbitrary ":" delimiter, not
    - # adding the delimiter if VAR is empty. I.e. a generalized:
    + # adding the delimiter if VAR or VALUE is empty. I.e. a generalized:
    +@@ t/test-lib.sh: 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
3:  ec852e6d691 < -:  ----------- test-lib: add "strip_path_prefix" to XSAN_OPTIONS
4:  2becf76a14a ! 4:  e6a48b6e4ce test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONS
    @@ t/test-lib.sh
     @@ t/test-lib.sh: prepend_var ASAN_OPTIONS : detect_leaks=0
      export ASAN_OPTIONS
      
    - prepend_var LSAN_OPTIONS : $XSAN_OPTIONS
    + prepend_var LSAN_OPTIONS : $GIT_XSAN_OPTIONS
     +prepend_var LSAN_OPTIONS : fast_unwind_on_malloc=0
      export LSAN_OPTIONS
      
-- 
2.35.1.1130.g7c6dd716f26
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 12 of 39 in “test-lib: improve LSAN + ASAN stack traces”
  1. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 18, 2022
  2. 1/4 test-lib: add XSAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 18, 2022
  3. Junio C HamanoFeb 18, 2022
  4. Taylor BlauFeb 19, 2022
  5. Ævar Arnfjörð BjarmasonFeb 19, 2022
  6. Taylor BlauFeb 19, 2022
  7. Ævar Arnfjörð BjarmasonFeb 19, 2022
  8. Taylor BlauFeb 19, 2022
  9. 2/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 18, 2022
  10. Junio C HamanoFeb 18, 2022
  11. Ævar Arnfjörð BjarmasonFeb 19, 2022
  12. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 19, 2022
  13. 1/4 test-lib: add GIT_XSAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 19, 2022
  14. Junio C HamanoFeb 20, 2022
  15. 2/4 test-lib: correct commentary on TEST_DIRECTORY overridingÆvar Arnfjörð Bjarmason, Feb 19, 2022
  16. 3/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 19, 2022
  17. 4/4 test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 19, 2022
  18. Taylor BlauFeb 21, 2022
  19. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 21, 2022
  20. 1/4 test-lib: add GIT_SAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 21, 2022
  21. 2/4 test-lib: correct commentary on TEST_DIRECTORY overridingÆvar Arnfjörð Bjarmason, Feb 21, 2022
  22. 3/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 21, 2022
  23. Taylor BlauFeb 21, 2022
  24. Ævar Arnfjörð BjarmasonFeb 21, 2022
  25. Junio C HamanoFeb 22, 2022
  26. Ævar Arnfjörð BjarmasonFeb 22, 2022
  27. Junio C HamanoFeb 23, 2022
  28. Ævar Arnfjörð BjarmasonFeb 24, 2022
  29. Junio C HamanoFeb 24, 2022
  30. 4/4 test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 21, 2022
  31. Taylor BlauFeb 21, 2022
  32. Ævar Arnfjörð BjarmasonFeb 21, 2022
  33. Junio C HamanoFeb 21, 2022
  34. Ævar Arnfjörð BjarmasonFeb 21, 2022
  35. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 27, 2022
  36. 1/4 test-lib: add GIT_SAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 27, 2022
  37. 2/4 test-lib: correct and assert TEST_DIRECTORY overridingÆvar Arnfjörð Bjarmason, Feb 27, 2022
  38. 3/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 27, 2022
  39. 4/4 test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 27, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.