Re: Invalid memory alloc request size for repeat()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Invalid memory alloc request size for repeat()
Дата
Msg-id 1926262.1653490252@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Invalid memory alloc request size for repeat()  (Japin Li <japinli@hotmail.com>)
Ответы Re: Invalid memory alloc request size for repeat()  (Japin Li <japinli@hotmail.com>)
Список pgsql-hackers
Japin Li <japinli@hotmail.com> writes:
> Today, I try to use repeat() to generate 1GB text, and it occurs invalid memory
> alloc request size [1].  It is a limit from palloc(), then I try to reduce it,
> it still complains out of memory which comes from enlargeStringInfo() [2].  The
> documentation about repect() [3] doesn't mentaion the limitation.

It would probably make sense for repeat() to check this explicitly:

    if (unlikely(pg_mul_s32_overflow(count, slen, &tlen)) ||
-       unlikely(pg_add_s32_overflow(tlen, VARHDRSZ, &tlen)))
+       unlikely(pg_add_s32_overflow(tlen, VARHDRSZ, &tlen)) ||
+       unlikely(!AllocSizeIsValid(tlen)))
        ereport(ERROR,
                (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
                 errmsg("requested length too large")));

The failure in enlargeStringInfo is probably coming from trying to
construct an output message to send back to the client.  That's
going to be a lot harder to do anything nice about (and even if
the backend didn't fail, the client might).

            regards, tom lane



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Invalid memory alloc request size for repeat()
Следующее
От: Matthias van de Meent
Дата:
Сообщение: Re: adding status for COPY progress report