Re: Reducing the chunk header sizes on all memory context types - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: Reducing the chunk header sizes on all memory context types
Date
Msg-id CAEudQApo3MVNTPFpeSUb+dhf3DbeMo3W0TigMc1gP_CsTd+jiw@mail.gmail.com
Whole thread Raw
In response to Reducing the chunk header sizes on all memory context types  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
Hi,
Excuse me for posting on this thread.

Coverity has a complaints about aset.c
CID 1497225 (#1 of 2): Out-of-bounds write (OVERRUN)3. overrun-local: Overrunning array set->freelist of 11 8-byte elements at element index 1073741823 (byte offset 8589934591) using index fidx (which evaluates to 1073741823).

CID 1497225 (#2 of 2): Out-of-bounds write (OVERRUN)3. overrun-local: Overrunning array set->freelist of 11 8-byte elements at element index 1073741823 (byte offset 8589934591) using index fidx (which evaluates to 1073741823).

I think that this is an oversight.

diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index b6eeb8abab..8f709514b2 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -1024,7 +1024,7 @@ AllocSetFree(void *pointer)
  }
  else
  {
- int fidx = MemoryChunkGetValue(chunk);
+ Size fidx = MemoryChunkGetValue(chunk);
  AllocBlock block = MemoryChunkGetBlock(chunk);
  AllocFreeListLink *link = GetFreeListLink(chunk);


MemoryChunkGetValue return Size not int.

Not sure if this fix is enough.

regards,
Ranier Vilela

pgsql-hackers by date:

Previous
From: Christoph Berg
Date:
Subject: Re: plpgsql-trigger.html: Format TG_ variables as table (patch)
Next
From: Nikita Glukhov
Date:
Subject: Re: SQL/JSON features for v15