]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/stack: fix segfault when reload with reused readers fails
authorPatrick Steinhardt <ps@pks.im>
Fri, 23 Aug 2024 14:12:57 +0000 (16:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 Aug 2024 15:04:48 +0000 (08:04 -0700)
commit85da2a2ab62e24a8b9ff183fe3a451b445632487
tree5c0f0af60471344da322772bb1c1af06082325e8
parent1302ed68d4f5452242d47ac609b06b793a18ea0b
reftable/stack: fix segfault when reload with reused readers fails

It is expected that reloading the stack fails with concurrent writers,
e.g. because a table that we just wanted to read just got compacted.
In case we decided to reuse readers this will cause a segfault though
because we unconditionally release all new readers, including the reused
ones. As those are still referenced by the current stack, the result is
that we will eventually try to dereference those already-freed readers.

Fix this bug by incrementing the refcount of reused readers temporarily.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/stack.c
reftable/stack_test.c