pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #19836: Backend crash with large hash partition modulus
3+ messages / 2 participants
[nested] [flat]
Commits from this thread:
2026-11-10 e455a8a8bb 3fe8f2c35e 61afc2ecdb 24f9d35108 d7e355bc0f 9f191dce61 Avoid integer wraparound when adding new HASH partition
* BUG #19836: Backend crash with large hash partition modulus
@ 2026-11-06 17:50 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: PG Bug reporting form @ 2026-11-06 17:50 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: sumedhpathak@gmail.com
The following bug has been logged on the website:
Bug reference: 19836
Logged by: Sumedh Pathak
Email address: sumedhpathak@gmail.com
PostgreSQL version: 19rc1
Operating system: MacOS
Description:
Hi,
The following SQL crashes PostgreSQL 20devel (72b9498df9a, macOS ARM64):
CREATE TABLE parent (i integer) PARTITION BY HASH (i);
CREATE TABLE p0 PARTITION OF parent
FOR VALUES WITH (MODULUS 3, REMAINDER 0);
CREATE TABLE p1 PARTITION OF parent
FOR VALUES WITH (MODULUS 2147483646, REMAINDER 2);
The third statement causes a crash and server recovery. In
check_new_partition_bound(), remainder += spec->modulus overflows signed int
(2 + 2147483646), leading to an out-of-bounds lookup. The crash was verified
on PG 17,18 as well, but it seems like it exists since PG11.
Thanks.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #19836: Backend crash with large hash partition modulus
@ 2026-11-09 00:10 David Rowley <dgrowleyml@gmail.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: David Rowley @ 2026-11-09 00:10 UTC (permalink / raw)
To: sumedhpathak@gmail.com; pgsql-bugs@lists.postgresql.org
On Sun, 8 Nov 2026 at 04:54, PG Bug reporting form
<noreply@postgresql.org> wrote:
> The following SQL crashes PostgreSQL 20devel (72b9498df9a, macOS ARM64):
> CREATE TABLE parent (i integer) PARTITION BY HASH (i);
> CREATE TABLE p0 PARTITION OF parent
> FOR VALUES WITH (MODULUS 3, REMAINDER 0);
> CREATE TABLE p1 PARTITION OF parent
> FOR VALUES WITH (MODULUS 2147483646, REMAINDER 2);
Thanks for the report.
It seems fine to just do:
@@ -2919,8 +2919,8 @@ check_new_partition_bound(char *relname, Relation parent,
if (partdesc->nparts > 0)
{
- int
greatest_modulus;
- int remainder;
+ int64 greatest_modulus;
+ int64 remainder;
That'll prevent the wrap and allow the do/while loop to terminate when
remainder is >= greatest_modulus. Bumping greatest_modulus isn't
really required, but I did that because I thought it was neater to
keep them the same size.
I can patch this when the freeze is over.
David
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #19836: Backend crash with large hash partition modulus
@ 2026-11-10 22:51 David Rowley <dgrowleyml@gmail.com>
parent: David Rowley <dgrowleyml@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: David Rowley @ 2026-11-10 22:51 UTC (permalink / raw)
To: sumedhpathak@gmail.com; pgsql-bugs@lists.postgresql.org
On Mon, 9 Nov 2026 at 13:10, David Rowley <dgrowleyml@gmail.com> wrote:
> @@ -2919,8 +2919,8 @@ check_new_partition_bound(char *relname, Relation parent,
>
> if (partdesc->nparts > 0)
> {
> - int
> greatest_modulus;
> - int remainder;
> + int64 greatest_modulus;
> + int64 remainder;
>
> That'll prevent the wrap and allow the do/while loop to terminate when
> remainder is >= greatest_modulus. Bumping greatest_modulus isn't
> really required, but I did that because I thought it was neater to
> keep them the same size.
>
> I can patch this when the freeze is over.
Pushed.
David
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-10 22:51 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 17:50 BUG #19836: Backend crash with large hash partition modulus PG Bug reporting form <noreply@postgresql.org>
2026-11-09 00:10 ` David Rowley <dgrowleyml@gmail.com>
2026-11-10 22:51 ` David Rowley <dgrowleyml@gmail.com>
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