Integer undeflow in fprintf in dsa.c
Ilyasov Ian <ianilyasov@outlook.com>
From: Ильясов Ян <ianilyasov@outlook.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2024-02-20T11:28:03Z
Lists: pgsql-hackers
Attachments
- Integer_underflow_fix_in_fprintf_in_dsa_c_.patch (text/x-patch) patch
Hello hackers,
Using Svace* I think I've found a little bug in src/backend/utils/mmgr/dsa.c.
This bug is presented in REL_12_STABLE, REL_13_STABLE, REL_14_STABLE,
REL_15_STABLE, REL_16_STABLE and master. I see that it was introduced together
with dynamic shared memory areas in the commit 13df76a537cca3b8884911d8fdf7c89a457a8dd3.
I also see that at least two people have encountered this fprintf output.
(https://postgrespro.com/list/thread-id/2419512,
https://www.postgresql.org/message-id/15e9501170d.e4b5a3858707.3339083113985275726%40zohocorp.com)
fprintf(stderr,
" segment bin %zu (at least %d contiguous pages free):\n",
i, 1 << (i - 1));
In case i equals zero user will get "at least -2147483648 contiguous pages free".
I believe that this is a mistake, and fprintf should print "at least 0 contiguous pages free"
in case i equals zero.
The patch that has a fix of this is attached.
* - https://svace.pages.ispras.ru/svace-website/en/
Kind regards,
Ian Ilyasov.
Juniour Software Developer at Postgres Professional
Commits
-
Fix integer underflow in shared memory debugging
- d5c3d6ca0152 13.15 landed
- a30a305584b8 16.3 landed
- 6fd144e3a966 17.0 landed
- 55ea12a28277 15.7 landed
- 24dc4afebd5a 12.19 landed
- 217928ddb45a 14.12 landed
-
Introduce dynamic shared memory areas.
- 13df76a537cc 10.0 cited