Re: BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow)

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: hackerzheng666(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow)
Date: 2026-11-16 18:49:14
Message-ID: 2621AACA-0173-4C97-99DA-F73B257BDFAA@yesql.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On 16 Nov 2026, at 19:37, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Daniel Gustafsson <daniel(at)yesql(dot)se> writes:

>>> On 15 Nov 2026, at 05:49, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
>>> Clamping len
>>> to MaxAllocSize - VARHDRSZ (or raising "requested length too large" before
>>> the allocation, as lo_get() style paths do) would give a proper message.
>
>> As far as bugs go, this is pretty low on the prioritylist; but since I had a
>> look at it I think we should error out like lo_get().
>
> Is it really worth the trouble at all?

Not really, other than the relaxing feeling of simple patches when one need a
mental break over a coffee.

> (It's not just your time to
> commit this, it's that you're loading more work on the translators.)

I made sure to re-use an exsting error message from the large object code to
avoid translation work for no reason. Otherwise this would've been net-negative
for sure.

> I don't see any non-nefarious case in which we'd hit this error,
> so letting the palloc error come out seems fine to me.

Same here, I can't see any risk.

--
Daniel Gustafsson

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ayush Tiwari 2026-11-16 18:56:09 Re: BUG #19906: Backend crash (signal 11) creating a LANGUAGE sql function that returns a composite type from a sub-
Previous Message Tom Lane 2026-11-16 18:37:42 Re: BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow)