forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf2369bc
committed
Use Size instead of int64 to track allocated memory
Commit5dd7fc1 added block-level memory accounting, but used int64 variable totrack the amount of allocated memory. That is incorrect, because we have Size forexactly these purposes, but it was mostly harmless untilc477f3e which changedhow we handle with repalloc() when downsizing the chunk. Previously we've ignoredthese cases and just kept using the original chunk, but now we need to update theaccounting, and the code was doing this: context->mem_allocated += blksize - oldblksize;Both blksize and oldblksize are Size (so unsigned) which means the subtractionunderflows, producing a very high positive value. On 64-bit platforms (where Sizehas the same size as mem_alllocated) this happens to work because the result wrapsto 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.us1 parent967e276 commitf2369bc
File tree
3 files changed
+6
-4
lines changed- src
- backend/utils/mmgr
- include/nodes
3 files changed
+6
-4
lines changedLines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1154 | 1154 |
| |
1155 | 1155 |
| |
1156 | 1156 |
| |
1157 |
| - | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
1158 | 1160 |
| |
1159 | 1161 |
| |
1160 | 1162 |
| |
| |||
1427 | 1429 |
| |
1428 | 1430 |
| |
1429 | 1431 |
| |
1430 |
| - | |
| 1432 | + | |
1431 | 1433 |
| |
1432 | 1434 |
| |
1433 | 1435 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
753 | 753 |
| |
754 | 754 |
| |
755 | 755 |
| |
756 |
| - | |
| 756 | + | |
757 | 757 |
| |
758 | 758 |
| |
759 | 759 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
82 |
| - | |
| 82 | + | |
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
|
0 commit comments
Comments
(0)