pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add workaround to make ubsan and ps_status.c compatible
Date: Mon, 21 Nov 2022 22:01:02 +0000
Message-ID: <E1oxEqb-000GmH-Jn@gemulon.postgresql.org> (raw)

Add workaround to make ubsan and ps_status.c compatible

At least on linux, set_ps_display() breaks /proc/$pid/environ. The sanitizer's
helper library uses /proc/$pid/environ to implement getenv(), as it wants to
work independent of libc. When just using undefined and alignment sanitizers,
the sanitizer library is only initialized when the first error occurs, by
which time we've often already called set_ps_display(), preventing the
sanitizer libraries from seeing the options.

We can work around that by defining __ubsan_default_options, a weak symbol
libsanitizer uses to get defaults from the application, and return
getenv("UBSAN_OPTIONS"). But only if main already was reached, so that we
don't end up relying on a not-yet-working getenv().

As it's just a function that won't get called when not running a sanitizer, it
doesn't seem necessary to make compilation of the function conditional.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f686ae82f2d7e29facde8300209deef7abe13605

Modified Files
--------------
src/backend/main/main.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)



Message-ID: <E1oxEqb-000GmH-Jn@gemulon.postgresql.org>
Permalink:  ../E1oxEqb-000GmH-Jn@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oxEqb-000GmH-Jn@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: pgsql: Add workaround to make ubsan and ps_status.c compatible
  In-Reply-To: <E1oxEqb-000GmH-Jn@gemulon.postgresql.org>
  References: <E1oxEqb-000GmH-Jn@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox