pgsql: Exclude the variables in llvmjit_types.c from AddressSanitizer

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Exclude the variables in llvmjit_types.c from AddressSanitizer
Date: 2026-11-07 02:07:12
Message-ID: E1xPVpo-00000000Xp8-2btB@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Exclude the variables in llvmjit_types.c from AddressSanitizer

If address sanitizer is enabled, types of global variables are changed
to a container type, to include space for a red zone after each global
variable. Unfortunately, that causes mismatches with the generated code,
which in turn causes crashes when JIT is combined with ASAN.

This does not normally present a problem with autoconf builds, as we do
not pass CFLAGS on to bitcode generation, so in autoconf builds the
bitcode generation never sees sanitizer flags. Somewhat similarly, in
meson builds, c_args were not passed on to bitcode generation, but that
was changed with 1039352e1 in 17.

For now, just use #pragma to exclude global variables in llvmjit_types.c
from address sanitizer.

That might not be the best fix medium term, but we need a short-term
fix, due to an upcoming fix's tests hitting this issue.

We did not notice this historically as with cirrus-ci address sanitizer
was tested with autoconf, which does not have this specific issue. The
GHA based CI was only added after JIT was disabled by default.

For now this is just backpatched to 17, as earlier branches
a) don't have pg_attribute_no_sanitize_address()
b) don't currently need it, due to 1039352e1 only being in >= 17

Author: Henson Choi <assam258(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAAAe_zA49cHXJ7J4hmeuSa75s+eSgCOnK_9Uvq6wUEJ2Bgvdfg@mail.gmail.com
Backpatch-through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1da6ddbdc32c5bf640429828bc0353ffcb40628e

Modified Files
--------------
src/backend/jit/llvm/llvmjit_types.c | 10 ++++++++++
1 file changed, 10 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2026-11-07 02:44:01 pgsql: doc PG 19 relnotes: add item about shared parallel vacuum cost
Previous Message Andres Freund 2026-11-07 00:30:17 pgsql: ci: Move to per-job naming for containers