Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAVsM-0008EO-96 for pgsql-bugs@arkaria.postgresql.org; Tue, 25 Aug 2020 10:08:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kAVsL-0000qm-8T for pgsql-bugs@arkaria.postgresql.org; Tue, 25 Aug 2020 10:08:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAVkY-0007Kd-G9 for pgsql-bugs@lists.postgresql.org; Tue, 25 Aug 2020 10:00:19 +0000 Received: from wforward3-smtp.messagingengine.com ([64.147.123.22]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAVkU-00065b-83 for pgsql-bugs@postgresql.org; Tue, 25 Aug 2020 10:00:18 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.west.internal (Postfix) with ESMTP id 372658EE; Tue, 25 Aug 2020 06:00:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 25 Aug 2020 06:00:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=yptpn5GkEiT6TVArSELNNRFuj6Oq1KN3t/m4nsnjZ z0=; b=EPJfCz0nCoaZYGlyGAxDD/cfxN2SUltRHovpqWjgNfRkbV0y4hZuxZwZU ASO2Nitd31gJM/2eua6Hi+MUOd48IlYTx+/VKtGHrZhuuYcS71vOKHDkwnMin70a DdCqxFD85EICSCLxv8rsjKEzWYD6CZqwawRU1mRxrspSSxD8g0dQYhzbi/qIXPSE S2zU4cR/ehCrbaoo/ccPlCP76yOqNB76EP47bs8ztpNUR3bGg+fJc3nWRS5l/j3k 5BP9+BYgR2vlCQvOQkSm3Qu1Zs16GVhROVLZD8ieR7Tmy9L58DXUFTcPab2KWlBY HjT+sphO6fFGGfm/X6Vh2IU9qsv1w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddvtddgvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhohfkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnug hquhgrughrrghnthdrtghomheqnecuggftrfgrthhtvghrnheptdevgeehtdejvdevvdel jeeuveejjedtleelgfekleefieekjeelgfektdduuedvnecuffhomhgrihhnpedvnhguqh hurggurhgrnhhtrdgtohhmnecukfhppeeluddrudegrddvvdehrdeludenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvg hnthhrrghuthesvdhnughquhgrughrrghnthdrtghomh X-ME-Proxy: Received: from april.pezone.net (p5b0ee15b.dip0.t-ipconnect.de [91.14.225.91]) by mail.messagingengine.com (Postfix) with ESMTPA id DAAD73060272; Tue, 25 Aug 2020 06:00:07 -0400 (EDT) Subject: Re: invalid alloc size error possible in shm_mq To: Markus Wanner , pgsql-bugs@postgresql.org, Robert Haas References: <3bb363e7-ac04-0ac4-9fe8-db1148755bfa@2ndquadrant.com> From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <3e428657-26ce-ed05-a7cf-7f2a546c2672@2ndquadrant.com> Date: Tue, 25 Aug 2020 12:00:06 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <3bb363e7-ac04-0ac4-9fe8-db1148755bfa@2ndquadrant.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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