git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] leak tests: mark remaining tests leak-free as such
@ 2023-08-24 18:40 Taylor Blau
  2023-08-24 18:40 ` [PATCH 1/3] leak tests: mark a handful of tests as leak-free Taylor Blau
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Taylor Blau @ 2023-08-24 18:40 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Teng Long, Ævar Arnfjörð Bjarmason

While working on another topic that cleared up some leaks, I wanted to
see if any new tests became leak-free, so I ran:

    $ make SANITIZE=leak
    $ make GIT_TEST_PASSING_SANITIZE_LEAK=check GIT_TEST_OPTS=-i test

, and was surprised to see so many tests appear in the "failed" list
(indicating that they are free of leaks, but did not mark themselves as
such).

In fact, the patch I had written at the time didn't make a dent one way
or another in the list of leak-free tests, as the same results were
produced on 'master' without my changes.

This series marks all leak-free tests as such, meaning that the above
"make test" invocation will pass after this series. The bulk of the
tests which are marked here in the first patch were always
leak-free[^1]. The remaining two patches address a couple of special
cases of tests which are also leak-free.

Thanks in advance for your review!

[^1]: At least as far back as v2.38.0, when the "check" mode of
  GIT_TEST_PASSING_SANITIZE_LEAK was first introduced.

Taylor Blau (3):
  leak tests: mark a handful of tests as leak-free
  leak tests: mark t3321-notes-stripspace.sh as leak-free
  leak tests: mark t5583-push-branches.sh as leak-free

 t/t3321-notes-stripspace.sh | 1 +
 t/t5571-pre-push-hook.sh    | 1 +
 t/t5583-push-branches.sh    | 1 +
 t/t7516-commit-races.sh     | 2 ++
 4 files changed, 5 insertions(+)

-- 
2.42.0.3.g4011eb6a8b

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [PATCH] test-lib: ignore uninteresting LSan output
@ 2022-09-08  5:17 Jeff King
  0 siblings, 0 replies; 22+ messages in thread
From: Jeff King @ 2022-09-08  5:17 UTC (permalink / raw)
  To: git; +Cc: Ævar Arnfjörð Bjarmason

When I run the tests in leak-checking mode the same way our CI job does,
like:

  make SANITIZE=leak \
       GIT_TEST_PASSING_SANITIZE_LEAK=true \
       GIT_TEST_SANITIZE_LEAK_LOG=true \
       test

then LSan can racily produce useless entries in the log files that look
like this:

  ==git==3034393==Unable to get registers from thread 3034307.

I think they're mostly harmless based on the source here:

  https://github.com/llvm/llvm-project/blob/7e0a52e8e9ef6394bb62e0b56e17fa23e7262411/compiler-rt/lib/lsan/lsan_common.cpp#L414

which reads:

    PtraceRegistersStatus have_registers =
        suspended_threads.GetRegistersAndSP(i, &registers, &sp);
    if (have_registers != REGISTERS_AVAILABLE) {
      Report("Unable to get registers from thread %llu.\n", os_id);
      // If unable to get SP, consider the entire stack to be reachable unless
      // GetRegistersAndSP failed with ESRCH.
      if (have_registers == REGISTERS_UNAVAILABLE_FATAL)
        continue;
      sp = stack_begin;
    }

The program itself still runs fine and LSan doesn't cause us to abort.
But test-lib.sh looks for any non-empty LSan logs and marks the test as
a failure anyway, under the assumption that we simply missed the failing
exit code somehow.

I don't think I've ever seen this happen in the CI job, but running
locally using clang-14 on an 8-core machine, I can't seem to make it
through a full run of the test suite without having at least one
failure. And it's a different one every time (though they do seem to
often be related to packing tests, which makes sense, since that is one
of our biggest users of threaded code).

We can hack around this by only counting LSan log files that contain a
line that doesn't match our known-uninteresting pattern.

Signed-off-by: Jeff King <peff@peff.net>
---
This feels awfully hacky, and maybe we should just throw it away unless
the CI job starts having problems. But I literally couldn't get through
a run without false positives, so at the very least I wanted to make
people aware of the problem and get that string into the list archive. ;)

 t/test-lib.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 377cc1c120..3951214cd5 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -324,6 +324,7 @@ nr_san_dir_leaks_ () {
 	find "$TEST_RESULTS_SAN_DIR" \
 		-type f \
 		-name "$TEST_RESULTS_SAN_FILE_PFX.*" 2>/dev/null |
+	xargs grep -lv "Unable to get registers from thread" |
 	wc -l
 }
 
-- 
2.37.3.1139.g47294c03c7



^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-08-29 16:44 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24 18:40 [PATCH 0/3] leak tests: mark remaining tests leak-free as such Taylor Blau
2023-08-24 18:40 ` [PATCH 1/3] leak tests: mark a handful of tests as leak-free Taylor Blau
2023-08-24 21:02   ` Jeff King
2023-08-25 19:05     ` Taylor Blau
2023-08-25 20:38       ` Jeff King
2023-08-28 18:24         ` Junio C Hamano
2023-08-28 18:37           ` [PATCH] test-lib: ignore uninteresting LSan output Jeff King
2023-08-24 18:40 ` [PATCH 2/3] leak tests: mark t3321-notes-stripspace.sh as leak-free Taylor Blau
2023-08-24 18:40 ` [PATCH 3/3] leak tests: mark t5583-push-branches.sh " Taylor Blau
2023-08-24 18:50 ` [PATCH 0/3] leak tests: mark remaining tests leak-free as such Junio C Hamano
2023-08-24 20:50 ` Jeff King
2023-08-24 20:54   ` Jeff King
2023-08-25 19:08   ` Taylor Blau
2023-08-25 20:35     ` Jeff King
2023-08-28 22:52 ` [PATCH v2 0/4] " Taylor Blau
2023-08-28 22:52   ` [PATCH v2 1/4] test-lib: ignore uninteresting LSan output Taylor Blau
2023-08-28 22:52   ` [PATCH v2 2/4] leak tests: mark a handful of tests as leak-free Taylor Blau
2023-08-28 22:53   ` [PATCH v2 3/4] leak tests: mark t3321-notes-stripspace.sh " Taylor Blau
2023-08-28 22:53   ` [PATCH v2 4/4] leak tests: mark t5583-push-branches.sh " Taylor Blau
2023-08-29  1:00   ` [PATCH v2 0/4] leak tests: mark remaining tests leak-free as such Jeff King
2023-08-29 16:43     ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2022-09-08  5:17 [PATCH] test-lib: ignore uninteresting LSan output Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).