From 72ebaa55cb153a5848c8e7528a4cb38834f0f5ed Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Wed, 10 Jun 2026 10:52:07 +0900 Subject: [PATCH v1] Add jit_crash regression test to force LLVM JIT compilation Add a small regression test that turns jit on and sets jit_above_cost, jit_optimize_above_cost and jit_inline_above_cost to zero, so that even trivial expressions are pushed through the LLVM JIT code generator. This exercises the JIT path unconditionally rather than relying on a query exceeding the default cost thresholds. The test contains no Row Pattern Recognition (or any other feature-specific) syntax; it is a plain aggregate over generate_series(). On a working installation it just returns the expected results. On environments with a broken LLVM JIT -- observed with libLLVM 19 built with debug info (-ggdb) under an AddressSanitizer backend -- any JIT-compiled expression crashes the backend with SIGILL inside llvm::DILocation::decodeDiscriminator(), independently of the SQL feature used. --- src/test/regress/expected/jit_crash.out | 39 +++++++++++++++++++++++++ src/test/regress/parallel_schedule | 5 ++++ src/test/regress/sql/jit_crash.sql | 32 ++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 src/test/regress/expected/jit_crash.out create mode 100644 src/test/regress/sql/jit_crash.sql diff --git a/src/test/regress/expected/jit_crash.out b/src/test/regress/expected/jit_crash.out new file mode 100644 index 00000000000..3f444f09019 --- /dev/null +++ b/src/test/regress/expected/jit_crash.out @@ -0,0 +1,39 @@ +-- +-- JIT_CRASH +-- +-- Minimal NON-RPR test that forces the JIT code generator to run. On a +-- working installation it simply returns the aggregate results below. On +-- environments where LLVM JIT is broken (observed with libLLVM 19 built with +-- -ggdb under an AddressSanitizer backend) the backend dies with +-- "client backend ... was terminated by signal 4: Illegal instruction" +-- inside llvm::DILocation::decodeDiscriminator(). The crash is independent of +-- any particular SQL feature: any expression pushed through the JIT compiler +-- triggers it. +-- +SET jit = on; +SET jit_above_cost = 0; +SET jit_optimize_above_cost = 0; +SET jit_inline_above_cost = 0; +-- (1) simplest possible JIT-compiled scalar expression +SELECT count(*) +FROM (SELECT i, i * 2 + 1 AS x + FROM generate_series(1, 100000) i + WHERE i % 3 = 0) t; + count +------- + 33333 +(1 row) + +-- (2) JIT-compiled aggregate over deformed tuples +SELECT sum(a + b) AS s +FROM (SELECT i AS a, i * 2 AS b + FROM generate_series(1, 100000) i) t; + s +------------- + 15000150000 +(1 row) + +RESET jit; +RESET jit_above_cost; +RESET jit_optimize_above_cost; +RESET jit_inline_above_cost; diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index 8fa0a6c47fb..c30b71ff591 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -143,6 +143,11 @@ test: event_trigger_login # this test also uses event triggers, so likewise run it by itself test: fast_default +# jit_crash forces the JIT compiler and crashes the backend on environments +# with a broken LLVM JIT (e.g. libLLVM 19 + AddressSanitizer); run it by +# itself so a crash does not take down any concurrent tests. +test: jit_crash + # run tablespace test at the end because it drops the tablespace created during # setup that other tests may use. test: tablespace diff --git a/src/test/regress/sql/jit_crash.sql b/src/test/regress/sql/jit_crash.sql new file mode 100644 index 00000000000..fe67fa96a74 --- /dev/null +++ b/src/test/regress/sql/jit_crash.sql @@ -0,0 +1,32 @@ +-- +-- JIT_CRASH +-- +-- Minimal NON-RPR test that forces the JIT code generator to run. On a +-- working installation it simply returns the aggregate results below. On +-- environments where LLVM JIT is broken (observed with libLLVM 19 built with +-- -ggdb under an AddressSanitizer backend) the backend dies with +-- "client backend ... was terminated by signal 4: Illegal instruction" +-- inside llvm::DILocation::decodeDiscriminator(). The crash is independent of +-- any particular SQL feature: any expression pushed through the JIT compiler +-- triggers it. +-- +SET jit = on; +SET jit_above_cost = 0; +SET jit_optimize_above_cost = 0; +SET jit_inline_above_cost = 0; + +-- (1) simplest possible JIT-compiled scalar expression +SELECT count(*) +FROM (SELECT i, i * 2 + 1 AS x + FROM generate_series(1, 100000) i + WHERE i % 3 = 0) t; + +-- (2) JIT-compiled aggregate over deformed tuples +SELECT sum(a + b) AS s +FROM (SELECT i AS a, i * 2 AS b + FROM generate_series(1, 100000) i) t; + +RESET jit; +RESET jit_above_cost; +RESET jit_optimize_above_cost; +RESET jit_inline_above_cost; -- 2.47.3