Re: Missing checks when malloc returns NULL... - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Missing checks when malloc returns NULL...
Date
Msg-id CAB7nPqRRR8mnM9kbGObV2tzP-BpmLotiKyVBPbY2bxjuAyeCpw@mail.gmail.com
Whole thread Raw
In response to Re: Missing checks when malloc returns NULL...  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Missing checks when malloc returns NULL...
Re: Missing checks when malloc returns NULL...
List pgsql-hackers
On Tue, Jun 21, 2016 at 10:46 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> 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.

OK, there is not much that we can do here then. What about the rest?
Those seem like legit concerns to me.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: signed division in hash_search_with_hash_value(ENTER) has high overhead
Next
From: Michael Paquier
Date:
Subject: Re: primary_conninfo missing from pg_stat_wal_receiver