From: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>
To: "Patrick Steinhardt" <ps@pks.im>, git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Randall S. Becker" <randall.becker@nexbridge.ca>
Subject: Re: [PATCH 4/4] reftable/basics: return NULL on zero-sized allocations
Date: Sat, 21 Dec 2024 13:53:29 +0100 [thread overview]
Message-ID: <1b833ccf-080d-4a92-afe2-3f469bc23dde@app.fastmail.com> (raw)
In-Reply-To: <20241221-b4-pks-reftable-oom-fix-without-readers-v1-4-12db83a3267c@pks.im>
On Sat, Dec 21, 2024, at 12:50, Patrick Steinhardt wrote:
> In the preceding commits we have fixed a couple of issues when
> allocating zero-sized objects. These issues were masked by
> implementation-defined behaviour. Quoting malloc(3p):
>
> If size is 0, either:
>
> * A null pointer shall be returned and errno may be set to an
> implementation-defined value, or
>
> * A pointer to the allocated space shall be returned. The
> application shall ensure that the pointer is not used to access an
> object.
>
> So it is perfectly valid that implementations of this function may or
> may not return a NULL pointer in such a case.
>
> Adapt both `reftable_malloc()` and `reftable_realloc()` so that they
> return NULL pointers on zero-sized allocations. This should remove any
> implementation-defined behaviour in our allocators and thus allows us to
> detect such platform-specific issues more easily going forward.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
Nice commit message.
next prev parent reply other threads:[~2024-12-21 12:53 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-21 11:50 [PATCH 0/4] reftable: fix out-of-memory errors on NonStop Patrick Steinhardt
2024-12-21 11:50 ` [PATCH 1/4] reftable/stack: don't perform auto-compaction with less than two tables Patrick Steinhardt
2024-12-21 17:08 ` Junio C Hamano
2024-12-21 17:51 ` Junio C Hamano
2024-12-22 7:13 ` Patrick Steinhardt
2024-12-21 11:50 ` [PATCH 2/4] reftable/merged: fix zero-sized allocation when there are no readers Patrick Steinhardt
2024-12-21 12:40 ` Kristoffer Haugsbakk
2024-12-21 14:18 ` Patrick Steinhardt
2024-12-21 17:13 ` Junio C Hamano
2024-12-21 11:50 ` [PATCH 3/4] reftable/stack: " Patrick Steinhardt
2024-12-21 17:36 ` Junio C Hamano
2024-12-21 17:57 ` Junio C Hamano
2024-12-21 18:06 ` rsbecker
2024-12-21 18:30 ` Junio C Hamano
2024-12-22 17:48 ` rsbecker
2024-12-22 18:17 ` rsbecker
2024-12-22 18:35 ` Patrick Steinhardt
2024-12-23 4:08 ` Junio C Hamano
2024-12-22 7:13 ` Patrick Steinhardt
2024-12-21 11:50 ` [PATCH 4/4] reftable/basics: return NULL on zero-sized allocations Patrick Steinhardt
2024-12-21 12:53 ` Kristoffer Haugsbakk [this message]
2024-12-21 15:05 ` [PATCH 0/4] reftable: fix out-of-memory errors on NonStop Randall Becker
2024-12-21 17:43 ` Junio C Hamano
2024-12-21 16:52 ` Junio C Hamano
2024-12-22 7:24 ` [PATCH v2 " Patrick Steinhardt
2024-12-22 7:24 ` [PATCH v2 1/4] reftable/stack: don't perform auto-compaction with less than two tables Patrick Steinhardt
2024-12-22 7:24 ` [PATCH v2 2/4] reftable/merged: fix zero-sized allocation when there are no readers Patrick Steinhardt
2024-12-22 7:24 ` [PATCH v2 3/4] reftable/stack: " Patrick Steinhardt
2024-12-22 7:24 ` [PATCH v2 4/4] reftable/basics: return NULL on zero-sized allocations Patrick Steinhardt
2024-12-22 16:31 ` [PATCH v2 0/4] reftable: fix out-of-memory errors on NonStop Junio C Hamano
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=1b833ccf-080d-4a92-afe2-3f469bc23dde@app.fastmail.com \
--to=kristofferhaugsbakk@fastmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
--cc=randall.becker@nexbridge.ca \
/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;
as well as URLs for NNTP newsgroup(s).