Skip to content

Commit 24dc4af

Browse files
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 <ianilyasov@outlook.com> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/GV1P251MB1004E0D09D117D3CECF9256ECD502@GV1P251MB1004.EURP251.PROD.OUTLOOK.COM Backpatch-through: v12
1 parent c0b4dad commit 24dc4af

File tree

1 file changed

+7
-3
lines changed
  • src/backend/utils/mmgr

1 file changed

+7
-3
lines changed

src/backend/utils/mmgr/dsa.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,9 +1093,13 @@ dsa_dump(dsa_area *area)
10931093
{
10941094
dsa_segment_index segment_index;
10951095

1096-
fprintf(stderr,
1097-
" segment bin %zu (at least %d contiguous pages free):\n",
1098-
i, 1 << (i - 1));
1096+
if (i == 0)
1097+
fprintf(stderr,
1098+
" segment bin %zu (no contiguous free pages):\n", i);
1099+
else
1100+
fprintf(stderr,
1101+
" segment bin %zu (at least %d contiguous pages free):\n",
1102+
i, 1 << (i - 1));
10991103
segment_index = area->control->segment_bins[i];
11001104
while (segment_index != DSA_SEGMENT_INDEX_NONE)
11011105
{

0 commit comments

Comments
 (0)