Re: LLVM JIT: any JIT-compiled query crashes (SIGILL) on a libLLVM 19 + ASAN build

From: Andres Freund <andres(at)anarazel(dot)de>
To: Henson Choi <assam258(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Noah Misch <noah(at)leadboat(dot)com>
Cc: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tatsuo Ishii <ishii(at)postgresql(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: LLVM JIT: any JIT-compiled query crashes (SIGILL) on a libLLVM 19 + ASAN build
Date: 2026-11-07 00:15:12
Message-ID: jlc4cv33seses5ttgnlzlvidvbzwsexwhxzc67db3frftf76m5@ttcoyo2vttkw
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-10-26 11:15:46 +0900, Henson Choi wrote:
> On an AddressSanitizer build, every JIT-compiled query crashes or
> hangs the backend while the JIT generates code for it, even "SELECT 1"
> with jit = on and jit_above_cost = 0. On Linux the backend dies of
> SIGILL; on macOS it loops forever inside LLVM.

I found the same thing a few days ago while reviewing another patch.

I was pretty confused as to why this was not an issue we noticed longer ago.

There's a bunch of annoying circumstances at hand here:

1) we used to not pass c_args to bitcode compilation, that was changed in 17,
with
Author: Peter Eisentraut <peter(at)eisentraut(dot)org>
Branch: master Release: REL_17_BR [1039352e1] 2024-06-06 22:36:43 +0200

meson: Add user-provided c_args to bitcode_cflags

This is needed for example to pass an include path set in the CPPFLAGS
environment variable to the bitcode compile command.

Discussion: https://www.postgresql.org/message-id/flat/c1384a7b-ed12-4862-a0da-a05c7945171a%40eisentraut.org

2) In autoconf I think we still don't (we IIRC pre-filter flags)

3) In cirrus-ci CI we used autoconf to build the asan build, so it would not
fail with asan

4) JIT was disabled by default on 19 / master just before we added github
actions based CI

That commit did not force-enable JIT in any test, which ain't optimal.

Because of a negative interaction with an upcoming fix, I plan to apply
Henson's 0004 to 17 to master.

In 16, the one older branch with meson support, it is not needed (see point 1
above), and in <= 16 pg_attribute_no_sanitize_address() didn't exist yet.

After the next set of minors we can polish this into a better state, with a
proper test and perhaps backpatching it all the way. Or going with a different
approach (like filtering c_args or replacing 1039352e1 with something else).

Unless somebody disagrees rather quickly with my plan?

Greetings,

Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2026-11-07 02:17:02 Re: First draft of PG 19 release notes
Previous Message Lejao, Kristian 2026-11-06 23:36:12 Use-after-free in ER_get_flat_size() when a PL/pgSQL expression references a TOASTed field and the whole record