Skip to content

reftable: handle allocation errors

Patrick Steinhardt requested to merge pks-reftable-allocation-errors into master

The reftable library provides pluggable allocators that can be switched out via reftable_set_alloc(). These pluggable allocators are not expected to behave like xmalloc() and friends -- in other words, they are allowed to fail. This is done such that the reftable library can truly behave like a library and let its callers handle such conditions.

It has been true since the inception of the reftable library that allocations may fail. But regardless of that we do not have any error handling for this scenario at all. Consequently, we can easily cause a segfault when running into an out-of-memory situation.

While the easy solution would be to plug in xmalloc() and friends such that we abort on these cases, that would contradict the very notion of what this library should be. Most importantly, I want to soonish revive the effort to implement a reftable backend in libgit2, and thus I have to make sure that the reftable library (of which we are the canonical upstream now) can be used in such contexts.

This patch series here is the first one in a set of series that will detangle the reftable library from the rest of the Git codebase again so that it becomes a true standalone library again that other projects can use.

The series is based on top of ed155187 (Sync with Git 2.46.1, 2024-09-13) with the following two depedencies merged into it to avoid conflicts:

  • cp/unit-test-reftable-stack at 2b14ced3 (t-reftable-stack: add test for stack iterators, 2024-09-08).

  • ps/reftable-exclude at adf7a0ce (refs/reftable: wire up support for exclude patterns, 2024-09-09).

Closes Handle allocation failures in the reftable library (#394 - closed).

Edited by Patrick Steinhardt

Merge request reports

Loading