Re: Out-of-memory error reports in libpq

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Out-of-memory error reports in libpq
Дата
Msg-id 606767.1627508244@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Out-of-memory error reports in libpq  (Andres Freund <andres@anarazel.de>)
Ответы Re: Out-of-memory error reports in libpq
Список pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> Hm. It seems we should be able to guarantee that the recovery path can print
> something, at least in the PGconn case. Is it perhaps worth pre-sizing
> PGConn->errorMessage so it'd fit an error like this?

Forgot to address this.  Right now, the normal situation is that
PGConn->errorMessage is "pre sized" to 256 bytes, because that's
what pqexpbuffer.c does for all PQExpBuffers.  So unless you've
overrun that, the question is moot.  If you have, and you got
an OOM in trying to expand the PQExpBuffer, then pqexpbuffer.c
will release what it has and substitute the "oom_buffer" empty
string.  If you're really unlucky you might then not be able
to allocate another 256-byte buffer, in which case we end up
with an empty-string result.  I don't think it's probable,
but in a multithread program it could happen.

> But perhaps that's more effort than it's worth.

Yeah.  I considered changing things so that oom_buffer contains
"out of memory\n" rather than an empty string, but I'm afraid
that that's making unsupportable assumptions about what PQExpBuffers
are used for.

For now, I'm content if it's not worse than v13.  We've not
heard a lot of complaints in this area.

            regards, tom lane



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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: [PATCH] test/ssl: rework the sslfiles Makefile target
Следующее
От: Peter Smith
Дата:
Сообщение: Re: Replace l337sp34k in comments.