tagcache: don't allow temp commit buffer to be moved

The temporary buffer used during database commit did not
have any buflib callbacks set, which allows it to be moved
by buflib at any time. The code is not prepared to deal
with this, so things break horribly if anything tries to
allocate during the commit.

The solution is to pass dummy callbacks to prevent the
buffer from being moved. I expect this may create other
issues since the commit uses up all available RAM, but
at least things won't get silently corrupted anymore.

Change-Id: I3183aaee58c94bfbaf4e24424030b8be6e341d22
This commit is contained in:
Aidan MacDonald 2022-01-18 18:20:53 +00:00
parent 525eb15864
commit aafe2dd2d1

View file

@ -326,7 +326,10 @@ static void allocate_tempbuf(void)
if (tempbuf) if (tempbuf)
tempbuf_size = size; tempbuf_size = size;
#else /* !__PCTOOL__ */ #else /* !__PCTOOL__ */
tempbuf_handle = core_alloc_maximum("tc tempbuf", &size, NULL); /* Need to pass dummy ops to prevent the buffer being moved
* out from under us, since we yield during the tagcache commit. */
static struct buflib_callbacks dummy_ops;
tempbuf_handle = core_alloc_maximum("tc tempbuf", &size, &dummy_ops);
if (tempbuf_handle > 0) if (tempbuf_handle > 0)
{ {
tempbuf = core_get_data(tempbuf_handle); tempbuf = core_get_data(tempbuf_handle);