Re: initdb SegFault

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: initdb SegFault
Дата
Msg-id 7379.1574176562@sss.pgh.pa.us
обсуждение исходный текст
Ответ на initdb SegFault  (vignesh C <vignesh21@gmail.com>)
Ответы Re: initdb SegFault  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
vignesh C <vignesh21@gmail.com> writes:
> createPQExpBuffer allocates memory and returns the pointer, there is a
> possibility that createPQExpBuffer can return NULL pointer in case of
> malloc failiure, but initdb's main function does not check this
> condition. During malloc failure when pointer is accessed it results
> in segmentation fault. Made changes to check and exit if
> createPQExpBuffer return's NULL pointer. Patch for the same is
> attached.

I can't get excited about this, for several reasons.

1) The probability of it happening in the field is not
distinguishable from zero, surely.  I imagine you forced this
failure by making a debugging malloc fail occasionally.

2) If we really are out of memory at this point, we'd have just as good
odds that some allocation request inside pg_log_error() would fail.
There's no practical way to ensure that that code path remains free
of malloc attempts.  (Not to mention cleanup_directories_atexit().)

3) In the end, an initdb failure is an initdb failure.  This change
doesn't improve robustness by any useful metric, it just adds an
untestable code path.  If we could recover somehow, it'd be more
interesting to spend time on.

BTW, looking at the small minority of places that bother to test
for createPQExpBuffer failure, the correct test for that seems
to be PQExpBufferBroken().

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nicolas Lutic
Дата:
Сообщение: Re: PITR on DROP DATABASE, deleting of the database directory despitethe recovery_target_time set before.
Следующее
От: Andres Freund
Дата:
Сообщение: Re: initdb SegFault