Re: invalid alloc size error possible in shm_mq

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Markus Wanner <markus(dot)wanner(at)2ndquadrant(dot)com>, pgsql-bugs(at)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: invalid alloc size error possible in shm_mq
Date: 2020-08-25 10:00:06
Message-ID: 3e428657-26ce-ed05-a7cf-7f2a546c2672@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2020-07-07 12:30, Markus Wanner wrote:
> in shm_mq_receive of shm_mq.c, a huge payload may trigger an unjustified
> "invalid memory alloc request size" error due to the way the buffer size
> is increased.
>
> I understand that this fine piece of infrastructure may not have been
> designed for huge payloads. I still argue it should better not fail
> that way for payloads between half a gigabyte and MaxAllocSize. The
> attached patch adds an appropriate assertion (documenting the upper
> limit) and avoids the error by limiting the allocation size to
> MaxAllocSize (to correct for such huge payloads below the limit).

I wonder if the assertion is appropriate or whether it should be a full
error check. Is anything on the sending side ensuring that the maximum
size is kept? All the size variables are Size/size_t so could be much
larger than MaxAllocSize.

Robert, thoughts?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2020-08-25 15:55:44 Re: ALTER TABLE ALTER COLUMN SET TYPE crash
Previous Message Michael Paquier 2020-08-25 06:05:11 Re: ALTER TABLE ALTER COLUMN SET TYPE crash