aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistbuild.c
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2019-10-04 16:10:56 +0200
committerTomas Vondra <tomas.vondra@postgresql.org>2019-10-04 16:10:56 +0200
commitf2369bc610a19563cc00054ccfe9089fac469641 (patch)
tree80c3b30d8bdf987d1b0768fb46c89e705b98f26a /src/backend/access/gist/gistbuild.c
parent967e276e9f6b485c8577371713a323bf277b6902 (diff)
downloadpostgresql-f2369bc610a19563cc00054ccfe9089fac469641.tar.gz
postgresql-f2369bc610a19563cc00054ccfe9089fac469641.zip
Use Size instead of int64 to track allocated memory
Commit 5dd7fc1519 added block-level memory accounting, but used int64 variable to track the amount of allocated memory. That is incorrect, because we have Size for exactly these purposes, but it was mostly harmless until c477f3e449 which changed how we handle with repalloc() when downsizing the chunk. Previously we've ignored these cases and just kept using the original chunk, but now we need to update the accounting, and the code was doing this: context->mem_allocated += blksize - oldblksize; Both blksize and oldblksize are Size (so unsigned) which means the subtraction underflows, producing a very high positive value. On 64-bit platforms (where Size has the same size as mem_alllocated) this happens to work because the result wraps to the right value, but on (some) 32-bit platforms this fails. This fixes two things - it changes mem_allocated (and related variables) to Size, and it splits the update to two separate steps, to prevent any underflows. Discussion: https://www.postgresql.org/message-id/15151.1570163761%40sss.pgh.pa.us
Diffstat (limited to 'src/backend/access/gist/gistbuild.c')
0 files changed, 0 insertions, 0 deletions