Re: Missing checks when malloc returns NULL...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Missing checks when malloc returns NULL...
Дата
Msg-id 7978.1466516782@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Missing checks when malloc returns NULL...  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: Missing checks when malloc returns NULL...
Список 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 по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Lets (not) break all the things. Was: [pgsql-advocacy] 9.6 -> 10.0
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: Precedence of new phrase search tsquery operator