Re: [BUG + PATCH] DSA pagemap out-of-bounds in make_new_segment odd-sized path - Mailing list pgsql-hackers

From Chao Li
Subject Re: [BUG + PATCH] DSA pagemap out-of-bounds in make_new_segment odd-sized path
Date
Msg-id BE7DBB95-BD78-446E-8026-68E9140B348B@gmail.com
Whole thread Raw
In response to Re: [BUG + PATCH] DSA pagemap out-of-bounds in make_new_segment odd-sized path  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers

> 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
OOBhappens, 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
Assertwould 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
usesit 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/







pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Why clearing the VM doesn't require registering vm buffer in wal record
Next
From: Jacob Champion
Date:
Subject: Re: [oauth] Stabilize the libpq-oauth ABI (and allow alternative implementations?)