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

From Tom Lane
Subject Re: Missing checks when malloc returns NULL...
Date
Msg-id 7978.1466516782@sss.pgh.pa.us
Whole thread Raw
In response to Missing checks when malloc returns NULL...  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Missing checks when malloc returns NULL...  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-hackers
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.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Lets (not) break all the things. Was: [pgsql-advocacy] 9.6 -> 10.0
Next
From: Teodor Sigaev
Date:
Subject: Re: Precedence of new phrase search tsquery operator