From: | Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> |
---|---|
To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se> |
Subject: | Re: [PoC] Federated Authn/z with OAUTHBEARER |
Date: | 2024-07-29 22:30:21 |
Message-ID: | CAOYmi+myshCL_yaWQiu54Kj5in93D5nPyw7yXj2jZnDKi73SHQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jul 29, 2024 at 5:02 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> We should take the check for exit() calls from libpq and expand it to
> cover the other libraries as well. Maybe there are other problems like
> this?
Seems reasonable, yeah.
> But under what circumstances does "the linker doesn't strip out" happen?
> If this happens accidentally, then we should have seen some buildfarm
> failures or something?
On my machine, for example, I see differences with optimization
levels. Say you inadvertently call pfree() in a _shlib build, as I did
multiple times upthread. By itself, that shouldn't actually be a
problem (it eventually redirects to free()), so it should be legal to
call pfree(), and with -O2 the build succeeds. But with -Og, the
exit() check trips, and when I disassemble I see that pg_malloc() et
all have infected the shared object. After all, we did tell the linker
to put that object file in, and we don't ask it to garbage-collect
sections.
> Also, one could look further and notice that restricted_token.c and
> sprompt.c both a) are not needed by libpq and b) can trigger exit()
> calls. Then it's not clear why those are not affected.
I think it's easier for the linker to omit whole object files rather
than partial ones. If libpq doesn't use any of those APIs there's not
really a reason to trip over it.
(Maybe the _shlib variants should just contain the minimum objects
required to compile.)
> I'm reminded of thread [0]. I think there is quite a bit of confusion
> about the pqexpbuffer vs. stringinfo APIs, and they are probably used
> incorrectly quite a bit. There are now also programs that use both of
> them! This patch now introduces another layer on top of them. I fear,
> at the end, nobody is going to understand any of this anymore.
"anymore"? :)
In all seriousness -- I agree that this isn't sustainable. At the
moment the worst pain (the new layer) is isolated to jsonapi.c, which
seems like an okay place to try something new, since there aren't that
many clients. But to be honest I'm not excited about deciding the Best
Way Forward based on a sample size of JSON.
> Also,
> changing all the programs to link in libpq for pqexpbuffer seems like
> the opposite direction from what was suggested in [0].
(I don't really want to keep that new libpq dependency. We'd just have
to decide where PQExpBuffer is going to go if we're not okay with it.)
> I think we need to do some deeper thinking here about how we want the
> memory management on the client side to work. Maybe we could just use
> one API but have some flags or callbacks to control the out-of-memory
> behavior.
Any src/common code that needs to handle both in-band and out-of-band
failure modes will still have to decide whether it's going to 1)
duplicate code paths or 2) just act as if in-band failures can always
happen. I think that's probably essential complexity; an ideal API
might make it nicer to deal with but it can't abstract it away.
Thanks!
--Jacob
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-07-29 22:31:36 | Re: Optimize mul_var() for var1ndigits >= 8 |
Previous Message | Daniel Gustafsson | 2024-07-29 22:25:59 | Re: ecdh support causes unnecessary roundtrips |