From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: __pg_log_level in anonynous enum should be initialized? (Was: pgsql: Change SHA2 implementation based on OpenSSL to use EVP digest ro)
Date: Tue, 29 Sep 2020 11:03:12 +0900
Message-ID: <20200929020312.GA10200@paquier.xyz> (raw)
In-Reply-To: <300644.1601311769@sss.pgh.pa.us>
References: <E1kMk96-0008Gm-7c@gemulon.postgresql.org>
<20200928073330.GC2316@paquier.xyz>
<300644.1601311769@sss.pgh.pa.us>
On Mon, Sep 28, 2020 at 12:49:29PM -0400, Tom Lane wrote:
> I experimented and confirmed that explicitly initializing __pg_log_level
> would suppress this build error on prairiedog. However, I'm not sure
> that doing so is a good idea, because it seems to me that this animal
> has accidentally saved us from a serious design error. IMO it is quite
> unacceptable for libpq to contain either a forced write to stderr or a
> forced exit(1). It should be reporting the failure back to the calling
> application, instead. So the error handling in this patch needs to be
> reconsidered.
Yeah, I have arrived at the same conclusion after a night of sleep and
after looking at the OpenSSL code for a couple of hours to see if it
would be possible to use a static state of EVP and not have to do all
this error handling. But, we are going to need much more than that,
so I have reverted the patch:
- Any allocation done with EVP is going to need a callback for the
cleanup in the backend, because we basically have to do the allocation
directly in OpenSSL. Not only for the higher EVP structure we get to
use in sha2_openssl.c, but also for some other parts at lower level,
like MD with EVP_MD_CTX_FLAG_NO_INIT.
- It will be better to have those routines return a status and just
let the caller handle the error. This impacts the internals of SCRAM,
particularly for the secret and internal HMAC implementations. And
this needs a change in the fallback implementation.
- We will most likely need to split the existing init and destroy
routines so as the initial allocation and final free happen in
different paths, even for the fallback implementation so as we have a
1:1 mapping with what OpenSSL does.
> Since prairiedog is not likely to be around forever, I propose that
> we ought to enforce this going forward by arranging for common/logging.c
> to not get built into the libpgcommon_shlib library variant.
Agreed. This makes sense in the long term, so attached is a proposal
of patch. I did not really see the point in complicating the MSVC
scripts for that though. The new variable names look natural to me
like that, the new comment may need some tweaks.
--
Michael
Attachments:common-shlib-split.patch (text/x-diff, 1.4K) downloaddiff --git a/src/common/Makefile b/src/common/Makefileindex f281762885..d0bbaefb1e 100644--- a/src/common/Makefile+++ b/src/common/Makefile@@ -88,13 +88,18 @@ OBJS_COMMON += sha2.o
endif
# A few files are currently only built for frontend, not server
-# (Mkvcbuild.pm has a copy of this list, too)+# (Mkvcbuild.pm has a copy of this list, too). logging.c is+# explicitely excluded from the shared library as it enforces some+# global state used for error reporting, that should never be used+# by libpq or similar.
OBJS_FRONTEND = \
$(OBJS_COMMON) \
fe_memutils.o \
- logging.o \
restricted_token.o \
sprompt.o
+OBJS_PGCOMMON = \+ $(OBJS_FRONTEND) \+ logging.o
# foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c
OBJS_SHLIB = $(OBJS_FRONTEND:%.o=%_shlib.o)
@@ -121,7 +126,7 @@ uninstall:
rm -f '$(DESTDIR)$(libdir)/libpgcommon.a'
rm -f '$(DESTDIR)$(libdir)/libpgcommon_shlib.a'
-libpgcommon.a: $(OBJS_FRONTEND)+libpgcommon.a: $(OBJS_PGCOMMON)
rm -f $@
$(AR) $(AROPT) $@ $^
@@ -177,7 +182,7 @@ $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
# kwlist_d.h is in the distribution tarball, so it is not cleaned here.
clean distclean:
rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
- rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)+ rm -f $(OBJS_PGCOMMON) $(OBJS_SHLIB) $(OBJS_SRV)
maintainer-clean: distclean
rm -f kwlist_d.h
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
Subject: Re: __pg_log_level in anonynous enum should be initialized? (Was: pgsql: Change SHA2 implementation based on OpenSSL to use EVP digest ro)
In-Reply-To: <20200929020312.GA10200@paquier.xyz>
References: <E1kMk96-0008Gm-7c@gemulon.postgresql.org> <20200928073330.GC2316@paquier.xyz> <300644.1601311769@sss.pgh.pa.us> <20200929020312.GA10200@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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