Re: thread-safety: strerror_r() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: thread-safety: strerror_r()
Date
Msg-id 1276344.1725307000@sss.pgh.pa.us
Whole thread Raw
Responses Re: thread-safety: strerror_r()
List pgsql-hackers
Peter Eisentraut <peter@eisentraut.org> writes:
> I think we can apply these patches now to check this off the list of 
> not-thread-safe functions to check.

+1 for the first patch.  I'm less happy with

-    static char errbuf[36];
+    static char errbuf[128];

As a minor point, shouldn't this be

+    static char errbuf[PG_STRERROR_R_BUFLEN];

But the bigger issue is that the use of a static buffer makes
this not thread-safe, so having it use strerror_r to fill that
buffer is just putting lipstick on a pig.  If we really want
to make this thread-ready, we need to adopt the approach used
in libpq's fe-secure-openssl.c, where callers have to free the
buffer later.  Or maybe we could just palloc the result, and
trust that it's not in a long-lived context?

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: query_id, pg_stat_activity, extended query protocol
Next
From: Jehan-Guillaume de Rorthais
Date:
Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails