Remove fe_memutils from libpgcommon_shlib
authorPeter Eisentraut <[email protected]>
Mon, 12 Aug 2024 06:30:39 +0000 (08:30 +0200)
committerPeter Eisentraut <[email protected]>
Mon, 12 Aug 2024 06:30:39 +0000 (08:30 +0200)
libpq must not use palloc/pfree. It's not allowed to exit on allocation
failure, and mixing the frontend pfree with malloc is architecturally
unsound.

Remove fe_memutils from the shlib build entirely, to keep devs from
accidentally depending on it in the future.

Author: Jacob Champion <[email protected]>
Discussion: https://www.postgresql.org/message-id/CAOYmi+=pg=W5L1h=3MEP_EB24jaBu2FyATrLXqQHGe7cpuvwyg@mail.gmail.com

src/common/Makefile
src/common/meson.build

index 3d83299432b948b08e18f8371d514ba70c026845..89ef61c52a636168efb1fe9c2ec9087cab2d0e43 100644 (file)
@@ -102,14 +102,15 @@ endif
 # A few files are currently only built for frontend, not server.
 # logging.c is excluded from OBJS_FRONTEND_SHLIB (shared library) as
 # a matter of policy, because it is not appropriate for general purpose
-# libraries such as libpq to report errors directly.
+# libraries such as libpq to report errors directly.  fe_memutils.c is
+# excluded because libpq must not exit() on allocation failure.
 OBJS_FRONTEND_SHLIB = \
    $(OBJS_COMMON) \
-   fe_memutils.o \
    restricted_token.o \
    sprompt.o
 OBJS_FRONTEND = \
    $(OBJS_FRONTEND_SHLIB) \
+   fe_memutils.o \
    logging.o
 
 # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c
index de68e408fa395abc0c486a62429efb3b57256b2b..1a564e1dce19a81c6befdbee61e96429296fdc6a 100644 (file)
@@ -101,17 +101,18 @@ common_sources_cflags = {
 # A few files are currently only built for frontend, not server.
 # logging.c is excluded from OBJS_FRONTEND_SHLIB (shared library) as
 # a matter of policy, because it is not appropriate for general purpose
-# libraries such as libpq to report errors directly.
+# libraries such as libpq to report errors directly.  fe_memutils.c is
+# excluded because libpq must not exit() on allocation failure.
 
 common_sources_frontend_shlib = common_sources
 common_sources_frontend_shlib += files(
-  'fe_memutils.c',
   'restricted_token.c',
   'sprompt.c',
 )
 
 common_sources_frontend_static = common_sources_frontend_shlib
 common_sources_frontend_static += files(
+  'fe_memutils.c',
   'logging.c',
 )