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

Re: [PATCH v5 0/5] for-each-ref: introduce seeking functionality via '--start-after'

From
Jeff King <peff@peff.net>
Date
Jul 17, 2025, 22:09 UTC
Message-ID
<20250717220929.GB2244266@coredump.intra.peff.net>
In-Reply-To
<CAO_smVj4e0XOQyQr5sDyMZ8WPvqcBe2Y33DFHrED7C=VJnm4eg@mail.gmail.com>
On Thu, Jul 17, 2025 at 12:35:58PM -0700, Kyle Lippincott wrote:
Show 39 quoted lines
> > ==3275333==WARNING: MemorySanitizer: use-of-uninitialized-value
> >     #0 0x557bd886f4bb in git_mkstemps_mode ../wrapper.c:487:27
> >     #1 0x557bd886fb55 in git_mkstemp_mode ../wrapper.c:509:9
> >     #2 0x557bd8100d1a in create_tmpfile ../object-file.c:736:7
> >     #3 0x557bd80f1630 in start_loose_object_common ../object-file.c:781:7
> >     #4 0x557bd80f5203 in write_loose_object ../object-file.c:881:7
> >     #5 0x557bd80f4875 in write_object_file_flags ../object-file.c:1086:6
> >     #6 0x557bd80f9f65 in write_object_file ../object-file.h:181:9
> >     #7 0x557bd8101eb8 in index_mem ../object-file.c:1177:9
> >     #8 0x557bd80f8bd5 in index_core ../object-file.c:1247:10
> >     #9 0x557bd80f731d in index_fd ../object-file.c:1274:9
> >     #10 0x557bd80f95e4 in index_path ../object-file.c:1295:7
> >     #11 0x557bd831132d in add_to_index ../read-cache.c:771:7
> >     #12 0x557bd8313cb1 in add_file_to_index ../read-cache.c:804:9
> >     #13 0x557bd73f892c in add_files ../builtin/add.c:355:7
> >     #14 0x557bd73f4752 in cmd_add ../builtin/add.c:578:18
> >     #15 0x557bd7a38b6f in run_builtin ../git.c:480:11
> >     #16 0x557bd7a31d54 in handle_builtin ../git.c:746:9
> >     #17 0x557bd7a36644 in run_argv ../git.c:813:4
> >     #18 0x557bd7a30e09 in cmd_main ../git.c:953:19
> >     #19 0x557bd7a3ca01 in main ../common-main.c:9:11
> >     #20 0x7f7e3f02a4d7 in __libc_start_call_main
> > (/nix/store/g2jzxk3s7cnkhh8yq55l4fbvf639zy37-glibc-2.40-66/lib/libc.so.6+0x2a4d7)
> > (BuildId: f117ee0f586dfa828cbdd08e37393c8f04f6480a)
> >     #21 0x7f7e3f02a59a in __libc_start_main@GLIBC_2.2.5
> > (/nix/store/g2jzxk3s7cnkhh8yq55l4fbvf639zy37-glibc-2.40-66/lib/libc.so.6+0x2a59a)
> > (BuildId: f117ee0f586dfa828cbdd08e37393c8f04f6480a)
> >     #22 0x557bd7352b34 in _start (git+0x5db34)
> >
> > Possibly something we need to look into cleaning up.
> 
> I also saw those msan issues when trying `make
> CFLAGS=-fsanitize=memory CC=clang`, but not with Google's internal
> msan build. I don't know which variable in wrapper.c:487 it's
> complaining about - you'd think it'd be `letters`, but if it's `v`,
> then that potentially comes from OpenSSL or some other library, and
> that library would also need to be built with msan (which is why it's
> such a pain to get msan builds working - EVERY library needs to be
> built with memory sanitizer).

Yeah, presumably it is "v" from csprng_bytes(). If there are only a few such spots, we can manually "unpoison" memory coming from libraries. On my system, I didn't hit the case shown above but do have trouble with bytes coming back from zlib.

Applying this ancient patch:
  https://lore.kernel.org/git/20171004101932.pai6wzcv2eohsicr@sigill.intra.peff.net/

and building with "make SANITIZE=memory CC=clang" let me run t6302 to completion, modulo the bug that started this thread (and which I confirmed goes away both with MSan and valgrind with the fix Karthik posted).

Probably:
diff --git a/wrapper.c b/wrapper.c
index 2f00d2ac87..6a4c1c1c29 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -482,6 +482,8 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
 		if (csprng_bytes(&v, sizeof(v), 0) < 0)
 			return error_errno("unable to get random bytes for temporary file");
 
+		msan_unpoison(&v, sizeof(v));
+
 		/* Fill in the random bits. */
 		for (i = 0; i < num_x; i++) {
 			filename_template[i] = letters[v % num_letters];


on top of that would fix the problem you guys are seeing. I don't know
if that path leads to insanity, though. Using MSan-enabled libraries is
probably a better direction (should increase accuracy, and we don't have
to carry these manual annotations around).

-Peff
Previous: Kyle LippincottNext: Jeff King
Message 90 of 102 in “for-each-ref: introduce seeking functionality via '--skip-until'”
  1. 0/4 for-each-ref: introduce seeking functionality via '--skip-until'Karthik Nayak, Jul 1, 2025
  2. 2/4 ref-cache: remove unused function 'find_ref_entry()'Karthik Nayak, Jul 1, 2025
  3. Junio C HamanoJul 14, 2025
  4. 1/4 refs: expose `ref_iterator` via 'refs.h'Karthik Nayak, Jul 1, 2025
  5. 3/4 refs: selectively set prefix in the seek functionsKarthik Nayak, Jul 1, 2025
  6. Patrick SteinhardtJul 3, 2025
  7. Karthik NayakJul 3, 2025
  8. 4/4 for-each-ref: introduce a '--skip-until' optionKarthik Nayak, Jul 1, 2025
  9. Patrick SteinhardtJul 3, 2025
  10. Karthik NayakJul 3, 2025
  11. Patrick SteinhardtJul 3, 2025
  12. Junio C HamanoJul 1, 2025
  13. Karthik NayakJul 2, 2025
  14. Junio C HamanoJul 1, 2025
  15. Karthik NayakJul 2, 2025
  16. Karthik NayakJul 3, 2025
  17. Phillip WoodJul 2, 2025
  18. Karthik NayakJul 2, 2025
  19. Patrick SteinhardtJul 3, 2025
  20. Junio C HamanoJul 3, 2025
  21. Patrick SteinhardtJul 3, 2025
  22. Karthik NayakJul 3, 2025
  23. 0/4 for-each-ref: introduce seeking functionality via '--skip-until'Karthik Nayak, Jul 4, 2025
  24. 1/4 refs: expose `ref_iterator` via 'refs.h'Karthik Nayak, Jul 4, 2025
  25. 2/4 ref-cache: remove unused function 'find_ref_entry()'Karthik Nayak, Jul 4, 2025
  26. 3/4 refs: selectively set prefix in the seek functionsKarthik Nayak, Jul 4, 2025
  27. 4/4 for-each-ref: introduce a '--skip-until' optionKarthik Nayak, Jul 4, 2025
  28. Junio C HamanoJul 7, 2025
  29. Karthik NayakJul 7, 2025
  30. Andreas SchwabJul 4, 2025
  31. Karthik NayakJul 4, 2025
  32. Andreas SchwabJul 4, 2025
  33. Karthik NayakJul 4, 2025
  34. Andreas SchwabJul 4, 2025
  35. Karthik NayakJul 7, 2025
  36. Junio C HamanoJul 4, 2025
  37. Karthik NayakJul 7, 2025
  38. Phillip WoodJul 7, 2025
  39. Karthik NayakJul 8, 2025
  40. 0/4 for-each-ref: introduce seeking functionality via '--start-after'Karthik Nayak, Jul 8, 2025
  41. 1/4 refs: expose `ref_iterator` via 'refs.h'Karthik Nayak, Jul 8, 2025
  42. 2/4 ref-cache: remove unused function 'find_ref_entry()'Karthik Nayak, Jul 8, 2025
  43. 3/4 refs: selectively set prefix in the seek functionsKarthik Nayak, Jul 8, 2025
  44. Patrick SteinhardtJul 10, 2025
  45. Karthik NayakJul 11, 2025
  46. Junio C HamanoJul 14, 2025
  47. Karthik NayakJul 15, 2025
  48. Junio C HamanoJul 15, 2025
  49. Karthik NayakJul 16, 2025
  50. Junio C HamanoJul 16, 2025
  51. Junio C HamanoJul 16, 2025
  52. Karthik NayakJul 17, 2025
  53. Junio C HamanoJul 17, 2025
  54. 4/4 for-each-ref: introduce a '--start-after' optionKarthik Nayak, Jul 8, 2025
  55. Junio C HamanoJul 8, 2025
  56. Karthik NayakJul 9, 2025
  57. 0/4 for-each-ref: introduce seeking functionality via '--start-after'Karthik Nayak, Jul 11, 2025
  58. 2/4 ref-cache: remove unused function 'find_ref_entry()'Karthik Nayak, Jul 11, 2025
  59. 1/4 refs: expose `ref_iterator` via 'refs.h'Karthik Nayak, Jul 11, 2025
  60. 3/4 refs: selectively set prefix in the seek functionsKarthik Nayak, Jul 11, 2025
  61. Christian CouderJul 14, 2025
  62. Karthik NayakJul 15, 2025
  63. 4/4 for-each-ref: introduce a '--start-after' optionKarthik Nayak, Jul 11, 2025
  64. Christian CouderJul 14, 2025
  65. Junio C HamanoJul 14, 2025
  66. Karthik NayakJul 15, 2025
  67. Christian CouderJul 14, 2025
  68. Junio C HamanoJul 14, 2025
  69. Karthik NayakJul 15, 2025
  70. 0/5 for-each-ref: introduce seeking functionality via '--start-after'Karthik Nayak, Jul 15, 2025
  71. 1/5 refs: expose `ref_iterator` via 'refs.h'Karthik Nayak, Jul 15, 2025
  72. 2/5 ref-cache: remove unused function 'find_ref_entry()'Karthik Nayak, Jul 15, 2025
  73. Junio C HamanoJul 17, 2025
  74. Karthik NayakJul 17, 2025
  75. Junio C HamanoJul 17, 2025
  76. 3/5 refs: selectively set prefix in the seek functionsKarthik Nayak, Jul 15, 2025
  77. Jeff KingJul 17, 2025
  78. Karthik NayakJul 17, 2025
  79. Jeff KingJul 17, 2025
  80. 4/5 ref-filter: remove unnecessary else clauseKarthik Nayak, Jul 15, 2025
  81. 5/5 for-each-ref: introduce a '--start-after' optionKarthik Nayak, Jul 15, 2025
  82. Junio C HamanoJul 17, 2025
  83. Karthik NayakJul 22, 2025
  84. Junio C HamanoJul 15, 2025
  85. Kyle LippincottJul 17, 2025
  86. Jeff KingJul 17, 2025
  87. Kyle LippincottJul 17, 2025
  88. Karthik NayakJul 17, 2025
  89. Kyle LippincottJul 17, 2025
  90. Jeff KingJul 17, 2025
  91. Jeff KingJul 17, 2025
  92. Karthik NayakJul 21, 2025
  93. Jeff KingJul 21, 2025
  94. Karthik NayakJul 22, 2025
  95. Junio C HamanoJul 17, 2025
  96. ref-iterator-seek: correctly initialize the prefix_state for a new levelJunio C Hamano, Jul 23, 2025
  97. Kyle LippincottJul 23, 2025
  98. Jeff KingJul 23, 2025
  99. Karthik NayakJul 24, 2025
  100. Junio C HamanoJul 24, 2025
  101. ref-cache: set prefix_state when seekingKarthik Nayak, Jul 24, 2025
  102. Junio C HamanoJul 24, 2025

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.