From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: thread-safety: strerror_r() |
Date: | 2024-09-04 12:54:09 |
Message-ID: | 855d71a1-7470-4eb5-8340-574146827700@eisentraut.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 02.09.24 21:56, Tom Lane wrote:
> Peter Eisentraut <peter(at)eisentraut(dot)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?
Ok, I have committed the first patch. We can think about the best
solution for the second issue when we get to the business end of all
this. The current situation doesn't really prevent making any progress
on that.
From | Date | Subject | |
---|---|---|---|
Next Message | Bertrand Drouvot | 2024-09-04 12:58:47 | Re: Add parallel columns for seq scan and index scan on pg_stat_all_tables and _indexes |
Previous Message | Joel Jacobson | 2024-09-04 12:52:53 | Re: Optimize mul_var() for var1ndigits >= 8 |