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

[PATCH v2 1/4] test-lib: ignore uninteresting LSan output

From
Taylor Blau <me@ttaylorr.com>
Date
Aug 28, 2023, 22:52 UTC
Message-ID
<7dd42212c0b0debe40504cca474f2a5d9207155a.1693263171.git.me@ttaylorr.com>
In-Reply-To
<cover.1693263171.git.me@ttaylorr.com>
From: Jeff King <peff@peff.net>

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>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 t/test-lib.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 293caf0f20..5ea5d1d62a 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -334,6 +334,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.42.0.49.g03c54e21ee
Previous: Taylor BlauNext: Jeff King
Message 19 of 21 in “leak tests: mark remaining tests leak-free as such”
  1. 0/3 leak tests: mark remaining tests leak-free as suchTaylor Blau, Aug 24, 2023
  2. 2/3 leak tests: mark t3321-notes-stripspace.sh as leak-freeTaylor Blau, Aug 24, 2023
  3. 1/3 leak tests: mark a handful of tests as leak-freeTaylor Blau, Aug 24, 2023
  4. Jeff KingAug 24, 2023
  5. Taylor BlauAug 25, 2023
  6. Jeff KingAug 25, 2023
  7. Junio C HamanoAug 28, 2023
  8. test-lib: ignore uninteresting LSan outputJeff King, Aug 28, 2023
  9. 3/3 leak tests: mark t5583-push-branches.sh as leak-freeTaylor Blau, Aug 24, 2023
  10. Junio C HamanoAug 24, 2023
  11. Jeff KingAug 24, 2023
  12. Jeff KingAug 24, 2023
  13. Taylor BlauAug 25, 2023
  14. Jeff KingAug 25, 2023
  15. 0/4 leak tests: mark remaining tests leak-free as suchTaylor Blau, Aug 28, 2023
  16. 2/4 leak tests: mark a handful of tests as leak-freeTaylor Blau, Aug 28, 2023
  17. 4/4 leak tests: mark t5583-push-branches.sh as leak-freeTaylor Blau, Aug 28, 2023
  18. 3/4 leak tests: mark t3321-notes-stripspace.sh as leak-freeTaylor Blau, Aug 28, 2023
  19. 1/4 test-lib: ignore uninteresting LSan outputTaylor Blau, Aug 28, 2023
  20. Jeff KingAug 29, 2023
  21. Junio C HamanoAug 29, 2023

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.