postgresql/src
Fujii Masao 0fc2f533a9 Add guard to prevent recursive memory context logging.
Previously, if memory context logging was triggered repeatedly and
rapidly while a previous request was still being processed, it could
result in recursive calls to ProcessLogMemoryContextInterrupt().
This could lead to infinite recursion and potentially crash the process.

This commit adds a guard to prevent such recursion.
If ProcessLogMemoryContextInterrupt() is already in progress and
logging memory contexts, subsequent calls will exit immediately,
avoiding unintended recursive calls.

While this scenario is unlikely in practice, it's not impossible.
This change adds a safety check to prevent such failures.

Back-patch to v14, where memory context logging was introduced.

Reported-by: Robert Haas <robertmhaas@gmail.com>
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Atsushi Torikoshi <torikoshia@oss.nttdata.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Artem Gavrilov <artem.gavrilov@percona.com>
Discussion: https://postgr.es/m/CA+TgmoZMrv32tbNRrFTvF9iWLnTGqbhYSLVcrHGuwZvCtph0NA@mail.gmail.com
Backpatch-through: 14
2025-12-19 12:09:10 +09:00
..
backend Add guard to prevent recursive memory context logging. 2025-12-19 12:09:10 +09:00
bin Print new OldestXID value in pg_resetwal when it's being changed 2025-11-19 18:06:26 +02:00
common With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:08 -07:00
fe_utils In fmtIdEnc(), handle failure of enlargePQExpBuffer(). 2025-02-16 12:46:35 -05:00
include Assert lack of hazardous buffer locks before possible catalog read. 2025-12-16 16:13:55 -08:00
interfaces libpq: Prevent some overflows of int/size_t 2025-11-10 06:03:05 -08:00
makefiles Refactor DLSUFFIX handling 2022-03-25 08:56:02 +01:00
pl tests: Rename conflicting role names 2025-12-12 08:45:00 +09:00
port Fix POSIX compliance in pgwin32_unsetenv() for "name" argument 2025-10-21 08:08:40 +09:00
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:28:55 -04:00
test For inplace update, send nontransactional invalidations. 2025-12-16 16:13:55 -08:00
timezone Update time zone data files to tzdata release 2025b. 2025-04-30 11:14:10 -04:00
tools For inplace update, send nontransactional invalidations. 2025-12-16 16:13:55 -08:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:41 -04:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00