summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gustafsson2024-02-29 11:19:52 +0000
committerDaniel Gustafsson2024-02-29 11:19:52 +0000
commit6fd144e3a9664ea545d10008c48dceb6c4e9d38a (patch)
tree9a4ca148e6be940934b4a9f78e42612524546117
parentb3f6b14cf48ffa81084072f1fdeee2fe9df20746 (diff)
Fix integer underflow in shared memory debugging
dsa_dump would print a large negative number instead of zero for segment bin 0. Fix by explicitly checking for underflow and add special case for bin 0. Backpatch to all supported versions. Author: Ian Ilyasov <[email protected]> Reviewed-by: Robert Haas <[email protected]> Discussion: https://postgr.es/m/GV1P251MB1004E0D09D117D3CECF9256ECD502@GV1P251MB1004.EURP251.PROD.OUTLOOK.COM Backpatch-through: v12
-rw-r--r--src/backend/utils/mmgr/dsa.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/utils/mmgr/dsa.c b/src/backend/utils/mmgr/dsa.c
index a6b728ba9ff..b9e7f224d51 100644
--- a/src/backend/utils/mmgr/dsa.c
+++ b/src/backend/utils/mmgr/dsa.c
@@ -1113,9 +1113,13 @@ dsa_dump(dsa_area *area)
{
dsa_segment_index segment_index;
- fprintf(stderr,
- " segment bin %zu (at least %d contiguous pages free):\n",
- i, 1 << (i - 1));
+ if (i == 0)
+ fprintf(stderr,
+ " segment bin %zu (no contiguous free pages):\n", i);
+ else
+ fprintf(stderr,
+ " segment bin %zu (at least %d contiguous pages free):\n",
+ i, 1 << (i - 1));
segment_index = area->control->segment_bins[i];
while (segment_index != DSA_SEGMENT_INDEX_NONE)
{