From: Chao Li <li.evan.chao@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Sami Imseih <samimseih@gmail.com>
Cc: paul.bunn@icloud.com
Cc: pgsql-hackers@postgresql.org
Subject: Re: [BUG + PATCH] DSA pagemap out-of-bounds in make_new_segment odd-sized path
Date: Fri, 6 Mar 2026 08:54:35 +0800
Message-ID: <BE7DBB95-BD78-446E-8026-68E9140B348B@gmail.com> (raw)
In-Reply-To: <aaoIg049JvfqWBXN@paquier.xyz>
References: <044401dcabac$fe432490$fac96db0$@icloud.com>
<CAA5RZ0vtF+7Oc8HAOVWGmbfWBVTAb=7-u-knU11cw2V6Bgfgog@mail.gmail.com>
<aaoIg049JvfqWBXN@paquier.xyz>
> On Mar 6, 2026, at 06:49, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Thu, Mar 05, 2026 at 04:25:57PM -0600, Sami Imseih wrote:
>> With the above assert in place, the usable_pages of 879 ars you have
>> in test_dsa.c crashes
>> due to the assertion failure.
>
> Yep, the assertion looks useful to have in place.
>
While debugging the code, I used the same Assert, which helped quickly trigger the bug. Without the Assert, even if an OOB happens, it might not immediately crash.
But now that the bug has been identified and fixed, and the function is self-contained, I’m not sure how much the Assert would still help. Unless we are not sure whether the fix really works, otherwise I don’t think the Assert is necessary.
However, this is not a strong objection. If we do want to add the Assert, I notice the expression MAXALIGN(sizeof(dsa_segment_header)) + MAXALIGN(sizeof(FreePageManager)) appears multiple times, and the Assert actually uses it as well. We could add a local variable like:
```
size_t metadata_fixed_bytes =
MAXALIGN(sizeof(dsa_segment_header)) +
MAXALIGN(sizeof(FreePageManager));
```
That would help reduce code redundancy.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: li.evan.chao@gmail.com, michael@paquier.xyz, samimseih@gmail.com, paul.bunn@icloud.com
Subject: Re: [BUG + PATCH] DSA pagemap out-of-bounds in make_new_segment odd-sized path
In-Reply-To: <BE7DBB95-BD78-446E-8026-68E9140B348B@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox