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

Re: [PATCH 0/2] Rust hash cleanups

From
Jeff King <peff@peff.net>
Date
Jul 19, 2026, 08:07 UTC
Message-ID
<20260719080754.GA429688@coredump.intra.peff.net>
In-Reply-To
<20260719010842.17991-1-sandals@crustytoothpaste.net>
On Sun, Jul 19, 2026 at 01:08:40AM +0000, brian m. carlson wrote:
> Peff recently sent out a series to fix several memory leaks with our
> hashing code when not using the default block algorithm.  This series
> follows up with a few fixes to our Rust hash code, which calls the C
> code, to fix various memory problems.

Both of these look good to me (modulo my almost-zero knowledge of the Rust bits).

I was worried at first that I had introduced new problems with my fixes, but I think these are both pre-existing issues (really just variants of the cleanups I did in the C code).

For patch 1, an alternative is to switch git_hash_clone() to _not_ require initialization. But it introduces the leak problem in the opposite direction. E.g., hashfile_truncate() wants to overwrite existing state, so it would now need to discard() before cloning. I doubt it's worth the effort or risk of regression to save the tiny bit of effort spent on a few init-then-overwrite cases.

So the approach taken here makes sense (and obviously this is just following the C code's lead anyway).

-Peff
Previous: brian m. carlson
Message 4 of 4 in “Rust hash cleanups”
  1. 0/2 Rust hash cleanupsbrian m. carlson, Jul 19, 2026
  2. 2/2 rust: discard hash context when finishedbrian m. carlson, Jul 19, 2026
  3. 1/2 hash: initialize context before cloningbrian m. carlson, Jul 19, 2026
  4. Jeff KingJul 19, 2026

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.