From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Jacob Champion <pchampion(at)vmware(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se> |
Subject: | Preventing abort() and exit() calls in libpq |
Date: | 2021-06-26 21:29:29 |
Message-ID: | 3128896.1624742969@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
[ starting a new thread so as not to confuse the cfbot ]
I wrote:
> Michael Paquier <michael(at)paquier(dot)xyz> writes:
>> Good point. That's worse than just pfree() which is just a plain call
>> to free() in the frontend. We could have more policies here, but my
>> take is that we'd better move fe_memutils.o to OBJS_FRONTEND in
>> src/common/Makefile so as shared libraries don't use those routines in
>> the long term.
> Ugh. Not only is that bad, but your proposed fix doesn't fix it.
> At least in psql, and probably in most/all of our other clients,
> removing fe_memutils.o from libpq's link just causes it to start
> relying on the copy in the psql executable :-(. So I agree that
> some sort of mechanical enforcement would be a really good thing,
> but I'm not sure what it would look like.
After some thought I propose that what we really want is to prevent
any calls of abort() or exit() from inside libpq. Attached is a
draft patch to do that. This can't be committed as-is, because
we still have some abort() calls in there in HEAD, but if we could
get that cleaned up it'd work. Alternatively we could just disallow
exit(), which'd be enough to catch the problematic src/common files.
This relies on "nm" being able to work on shlibs, which it's not
required to by POSIX. However, it seems to behave as desired even
on my oldest dinosaurs. In any case, if "nm" doesn't work then
we'll just not detect such problems on that platform, which should
be OK as long as the test does work on common platforms.
Other than that point I think it's relying only on POSIX-spec
features.
I'll stick this into the CF list to see if the cfbot agrees that
it finds the abort() problems...
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
disallow-abort-and-exit-in-libpq-1.patch | text/x-diff | 842 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2021-06-26 21:40:15 | Re: Pipeline mode and PQpipelineSync() |
Previous Message | Tom Lane | 2021-06-26 19:22:43 | Re: [PATCH] Make jsonapi usable from libpq |