Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFM1x-0000hj-Ic for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jun 2016 13:47:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bFM1x-0001dH-57 for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jun 2016 13:47:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bFM0Z-0008A3-P3 for pgsql-hackers@postgresql.org; Tue, 21 Jun 2016 13:46:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bFM0W-0002MB-Va for pgsql-hackers@postgresql.org; Tue, 21 Jun 2016 13:46:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u5LDkMMc007979; Tue, 21 Jun 2016 09:46:22 -0400 From: Tom Lane To: Michael Paquier cc: PostgreSQL mailing lists Subject: Re: Missing checks when malloc returns NULL... In-reply-to: References: Comments: In-reply-to Michael Paquier message dated "Tue, 21 Jun 2016 13:47:32 +0900" Date: Tue, 21 Jun 2016 09:46:22 -0400 Message-ID: <7978.1466516782@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Michael Paquier writes: > - mcxt.c uses that, which is surprising: > @@ -704,7 +704,8 @@ MemoryContextCreate(NodeTag tag, Size size, > { > /* Special case for startup: use good ol' malloc */ > node = (MemoryContext) malloc(needed); > - Assert(node != NULL); > + if (node == NULL) > + elog(PANIC, "out of memory"); > } > I think that a PANIC is cleaner here instead of a simple crash. But the elog mechanism assumes that memory contexts are working. If this ever actually did fire, no good would come of it. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers