Re: [PATCH] Make jsonapi usable from libpq

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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: Re: [PATCH] Make jsonapi usable from libpq
Date: 2021-06-30 17:13:16
Message-ID: bf828721-ef3e-2a8a-feeb-ade81a4b8f91@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26.06.21 19:43, Tom Lane wrote:
> I spent some time looking for other undesirable symbol dependencies
> in libpq, and soon found a couple. PGTHREAD_ERROR potentially calls
> abort(), which seems even worse than exit-on-OOM, although I don't
> think we've ever heard a report of that being hit. Also,
> fe-print.c's handling of OOM isn't nice at all:
>
> fprintf(stderr, libpq_gettext("out of memory\n"));
> abort();
>
> Although fe-print.c is semi-deprecated, it still seems like it'd
> be a good idea to clean that up.

These abort() calls were put there on purpose by:

commit c6ea8ccea6bf23501962ddc7ac9ffdb99c8643e1
Author: Peter Eisentraut <peter_e(at)gmx(dot)net>
Date: Mon Jan 30 20:34:00 2012

Use abort() instead of exit() to abort library functions

In some hopeless situations, certain library functions in libpq and
libpgport quit the program. Use abort() for that instead of exit(),
so we don't interfere with the normal exit codes the program might
use, we clearly signal the abnormal termination, and the caller has a
chance of catching the termination.

This was originally pointed out by Debian's Lintian program.

I don't object to refining this, but I think it is a mischaracterization
to calls this kind of code wrong. And I'm dubious about the backpatching.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2021-06-30 17:24:26 Re: Preventing abort() and exit() calls in libpq
Previous Message John Naylor 2021-06-30 16:54:23 Re: speed up verifying UTF-8