pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix memory leak in Memoize cache key evaluation 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix memory leak in Memoize cache key evaluation @ 2023-03-20 00:30 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: David Rowley @ 2023-03-20 00:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Memoize cache key evaluation When probing the Memoize cache to check if the current cache key values exist in the cache, we perform an evaluation of the expressions making up the cache key before probing the hash table for those values. This operation could leak memory as it is possible that the cache key is an expression which requires allocation of memory, as was the case in bug 17844. Here we fix this by correctly switching to the per tuple context before evaluating the cache expressions so that the memory is freed next time the per tuple context is reset. Bug: 17844 Reported-by: Alexey Ermakov Discussion: https://postgr.es/m/17844-d2f6f9e75a622bed@postgresql.org Backpatch-through: 14, where Memoize was introduced Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/579ee5df14dfcf5213e502bb096121d2249167c2 Modified Files -------------- src/backend/executor/nodeMemoize.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix memory leak in Memoize cache key evaluation @ 2023-03-20 00:30 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: David Rowley @ 2023-03-20 00:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Memoize cache key evaluation When probing the Memoize cache to check if the current cache key values exist in the cache, we perform an evaluation of the expressions making up the cache key before probing the hash table for those values. This operation could leak memory as it is possible that the cache key is an expression which requires allocation of memory, as was the case in bug 17844. Here we fix this by correctly switching to the per tuple context before evaluating the cache expressions so that the memory is freed next time the per tuple context is reset. Bug: 17844 Reported-by: Alexey Ermakov Discussion: https://postgr.es/m/17844-d2f6f9e75a622bed@postgresql.org Backpatch-through: 14, where Memoize was introduced Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8de4660a57e6e165debc949d2cb922f60f8aa921 Modified Files -------------- src/backend/executor/nodeMemoize.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix memory leak in Memoize cache key evaluation @ 2023-03-20 00:31 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: David Rowley @ 2023-03-20 00:31 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leak in Memoize cache key evaluation When probing the Memoize cache to check if the current cache key values exist in the cache, we perform an evaluation of the expressions making up the cache key before probing the hash table for those values. This operation could leak memory as it is possible that the cache key is an expression which requires allocation of memory, as was the case in bug 17844. Here we fix this by correctly switching to the per tuple context before evaluating the cache expressions so that the memory is freed next time the per tuple context is reset. Bug: 17844 Reported-by: Alexey Ermakov Discussion: https://postgr.es/m/17844-d2f6f9e75a622bed@postgresql.org Backpatch-through: 14, where Memoize was introduced Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f654f343c6a89f76aa0385bb92a1c6802126974c Modified Files -------------- src/backend/executor/nodeMemoize.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-03-20 00:31 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-03-20 00:30 pgsql: Fix memory leak in Memoize cache key evaluation David Rowley <drowley@postgresql.org> 2023-03-20 00:30 pgsql: Fix memory leak in Memoize cache key evaluation David Rowley <drowley@postgresql.org> 2023-03-20 00:31 pgsql: Fix memory leak in Memoize cache key evaluation David Rowley <drowley@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox