Git development
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Patrick Steinhardt <ps@pks.im>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH 7/9] http: discard hash in dumb-http http_object_request
Date: Fri, 3 Jul 2026 13:47:06 +0000	[thread overview]
Message-ID: <ake9Wng-Q9p_sf_H@fruit.crustytoothpaste.net> (raw)
In-Reply-To: <akecqPq4F702E8Cq@pks.im>

[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]

On 2026-07-03 at 11:27:36, Patrick Steinhardt wrote:
> On Thu, Jul 02, 2026 at 04:07:07AM -0400, Jeff King wrote:
> > The flag handling could be removed if the hash-discard function were
> > idempotent. This could be done easily-ish by having the underlying
> > hash functions (like the ones in sha256/openssl.h) set the context
> > pointer to NULL after free-ing. But it's something that every platform
> > implementation would have to remember to do, and the benefit for the
> > callers is not that huge (it would let us shave a few lines here and
> > probably in a few other spots).
> 
> This answers an earlier question of mine. It would indeed be great if it
> was idempotent -- I've been bitten by interfaces like this once too
> much, where you have to be very careful to manage the lifetime of a
> specific object. The prime example of this are (were? I don't quite
> recall whether we fixed that interface) reference transactions, and that
> caused a bunch of bugs in the past.

Yes, that would be fantastic.  The Rust code will need a few fixes as
well (which I will send on top of this one when it's picked up) and it
really simplifies our Drop implementation if I can just do
`git_hash_discard`.  Otherwise, I need to keep track of whether we've
already called one of the final functions or not to avoid a double free.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 325 bytes --]

  reply	other threads:[~2026-07-03 13:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  7:52 [PATCH 0/9] hash algorithm leak fixes Jeff King
2026-07-02  7:57 ` [PATCH 1/9] csum-file: drop discard_hashfile() Jeff King
2026-07-02 18:19   ` Junio C Hamano
2026-07-02 21:06     ` Jeff King
2026-07-03 11:27       ` Patrick Steinhardt
2026-07-02  7:59 ` [PATCH 2/9] hash: add discard primitive Jeff King
2026-07-03 11:27   ` Patrick Steinhardt
2026-07-02  8:01 ` [PATCH 3/9] csum-file: always finalize or discard hash Jeff King
2026-07-02  8:03 ` [PATCH 4/9] csum-file: provide a function to release checkpoints Jeff King
2026-07-03 11:27   ` Patrick Steinhardt
2026-07-02  8:04 ` [PATCH 5/9] patch-id: discard hash when done Jeff King
2026-07-02  8:05 ` [PATCH 6/9] check_stream_oid(): discard hash on read error Jeff King
2026-07-02  8:07 ` [PATCH 7/9] http: discard hash in dumb-http http_object_request Jeff King
2026-07-03 11:27   ` Patrick Steinhardt
2026-07-03 13:47     ` brian m. carlson [this message]
2026-07-06  0:01     ` Jeff King
2026-07-06  0:44       ` Jeff King
2026-07-06  6:16       ` Patrick Steinhardt
2026-07-02  8:09 ` [PATCH 8/9] hash: fix memory leak copying sha256 gcrypt handles Jeff King
2026-07-02  8:13 ` [PATCH 9/9] hash: add platform-specific discard functions Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ake9Wng-Q9p_sf_H@fruit.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox