Skip to content

darwin fast test: disable JIT in macOS test runs - #106987

Closed
leshikus wants to merge 4 commits into
ClickHouse:masterfrom
leshikus:darwin-disable-jit
Closed

leshikus wants to merge 4 commits into
ClickHouse:masterfrom
leshikus:darwin-disable-jit

Conversation

@leshikus

Copy link
Copy Markdown
Collaborator

Follow-up for #105921.

Every Fast test (arm_darwin) run produces a SIGILL ("Illegal instruction") crash report on macOS 26. The suspected cause is JIT: JIT-compiled expressions allocate large objects on the stack, and the smaller default stack on macOS turns this into a stack overflow that surfaces as a SIGILL. A similar Darwin stack-size issue was handled in #102645.

As a reversible mitigation, this disables JIT at runtime via a users.d profile override (compile_expressions, compile_aggregate_expressions and compile_sort_description set to 0), applied only to the macOS fast test run. Linux runs and the production build are untouched, so this can be reverted easily once the macOS stack issue is resolved. If this proves insufficient, the next step is to disable JIT on Mac at build time.

Related: #105921
Related: #102645

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Follow-up for ClickHouse#105921.

Every `Fast test (arm_darwin)` run produces a `SIGILL` ("Illegal
instruction") crash report on `macOS 26`. The suspected cause is JIT:
JIT-compiled expressions allocate large objects on the stack, and the
smaller default stack on macOS turns this into a stack overflow that
surfaces as a `SIGILL`. A similar Darwin stack-size issue was handled in
ClickHouse#102645.

As a reversible mitigation, disable JIT at runtime via a `users.d`
profile override (`compile_expressions`, `compile_aggregate_expressions`
and `compile_sort_description` set to `0`) applied only to the macOS fast
test run. This keeps Linux runs and the production build untouched, so it
can be reverted easily once the macOS stack issue is resolved.
@clickhouse-gh

clickhouse-gh Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e6e2584]

Summary: ✅


AI Review

Summary

This PR tries to stabilize Fast test (arm_darwin) by disabling JIT and skipping known Darwin failures. The skip-list plumbing is scoped to Darwin, but the no-JIT profile override only changes defaults, so fast stateless tests can still re-enable JIT and enter the same macOS code path the PR is meant to avoid. I would request changes until the Darwin job makes that invariant enforceable.

Findings

⚠️ Majors

  • [ci/jobs/fast_test.py:142] The PR promises that the Darwin fast test disables JIT, but the generated profile only sets default values for compile_expressions, compile_aggregate_expressions, and compile_sort_description. clickhouse-test still runs fast, non-long tests that can override those settings with SET or SETTINGS; examples not skipped by ci/defs/darwin.skip include 00745_compile_scalar_subquery, 02724_jit_logical_functions, 03357_jit_strikes_again, 04072_jit_decimal_expressions, and 04240_intexp2_jit_overflow. Those tests can still enter LLVM codegen on macOS, so the mitigation does not reliably remove the stack-overflowing path from the job.
    Suggested fix: add profile constraints that prevent these Boolean settings from being raised above 0, for example <constraints><compile_expressions><max>0</max></compile_expressions>...</constraints>, or skip every remaining fast test that forces JIT on Darwin. A const constraint would also block SET compile_expressions = 0, so max=0 is less disruptive.
Tests

⚠️ Please rerun or otherwise prove Fast test (arm_darwin) with a JIT-forcing fast test such as 00745_compile_scalar_subquery or 04240_intexp2_jit_overflow. The important evidence is that attempts to set compile_expressions = 1, compile_aggregate_expressions = 1, or compile_sort_description = 1 cannot re-enable JIT in this job.

Final Verdict

Status: ⚠️ Request changes

Minimum required action: make the Darwin no-JIT override enforceable, or skip all remaining fast tests that can force JIT, then provide a Darwin fast-test run showing the mitigation holds.

@leshikus leshikus added the can be tested Allows running workflows for external contributors label Jun 10, 2026
@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 10, 2026
…nfig file

Write the macOS no-JIT users.d override from the fast test job itself
rather than committing it as tests/config/users.d/no_jit.xml. A file under
tests/config/users.d/ could occasionally be picked up by another test
configuration; generating it inline keeps it scoped to the macOS fast test
run only.
@Algunenano

Copy link
Copy Markdown
Member

@leshikus Could you please open an issue and provide a reproducer? Otherwise it won't be fixed

@leshikus

Copy link
Copy Markdown
Collaborator Author

@Algunenano I will definitely do that - but the first step is to check if disabling jit removes intermittent errors

@Algunenano

Copy link
Copy Markdown
Member

Confirmed and reproduced locally:

What the crash is

A stack overflow in a ClickHouse server thread during LLVM JIT codegen — not a macOS fork-safety guard.

Confirmed under lldb (catching 03109_ast_too_big.sql alone):
- EXC_BAD_ACCESS (code=2), fault address 0x16b0eb280 = sp+0x40, faulting on the stp store in getSortedExprStubs's prologue.
- sp = 0x16b0eb240 sits inside the thread's stack guard page (memory region $sp → [0x16b0e8000–0x16b0ec000) ---, no access).
- 67-frame coherent backtrace: TCPHandler::runImpl → executeQuery → QueryAnalyzer::resolve… → evaluateScalarSubqueryIfNeeded → buildQueryPipeline → AggregatingStep::transformPipeline → Aggregator ctor → compileAggregateFunctions → CHJIT → LLVM passes → AArch64AsmPrinter::emitEndOfAsmFile.

So the stack-hungry LLVM codegen runs synchronously, deep inside recursive scalar-subquery analysis (03109 nests 14 (SELECT avg(valN) FROM data) subqueries), on a connection-handler thread.

Why it's arm_darwin-only

server_pool (the TCP connection-handler pool, Server.cpp:1498) is created with stackSize = POCO_THREAD_STACK_SIZE = 0 → OS default. On macOS that's 512 KB; on Linux it's ulimit -s (~8 MB). LLVM codegen + the deep analyzer recursion overruns 512 KB. ClickHouse's soft checkStackSize() guard never fires because LLVM codegen doesn't call it, so the OS guard page is hit directly.
Reproduction (reliable, on this machine)

build_public 26.6.1 server with default config; run 03109_ast_too_big.sql on a single connection → server dies within ~2 runs. The earlier "needs 16 concurrent workers" impression was a red herring: concurrency just runs 03109 more often.

Comment thread ci/jobs/fast_test.py
config = """<clickhouse>
<profiles>
<default>
<compile_expressions>0</compile_expressions>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not actually disable JIT for the Darwin fast test. Values under <profiles><default> are just defaults, so a stateless test can still override them with SET or SETTINGS; for example tests/queries/0_stateless/00745_compile_scalar_subquery.sql has no no-fasttest tag and sets compile_expressions = 1, which still lets the server enter LLVM codegen on macOS. Since the PR is meant to remove the stack-overflowing JIT path from this job, please make these settings const/readonly in this override, or explicitly skip the remaining JIT-forcing tests on Darwin, instead of only changing the defaults.

@Algunenano

Copy link
Copy Markdown
Member

Fix for Darwin: #107033

@leshikus Maybe we can run the experimental darwin tests there? Not sure how to do it

@leshikus

Copy link
Copy Markdown
Collaborator Author

It seems disabling JIT really helped with intermittent problems

Add the 16 tests that fail in `Fast test (arm_darwin)` to `ci/defs/darwin.skip`.
Fourteen are distributed / `FileLog` / transaction / `system` tests that fail
outright; two (`03716_mutations_parts_in_progress_rmt_2` and
`03783_part_log_mutation_ids_rmt`) time out.

Extracted from the run:
https://github.com/ClickHouse/ClickHouse/actions/runs/27286787681/job/80629773460?pr=106987
…tions

The test passes (`stdout: ok`) but leaks `ConnectionPoolWithFailover` connect
timeouts to `127.0.0.2:9000` on stderr, which `clickhouse-test` reports as
`having stderror`. The macOS run masks it behind `force_success=True`, so the
job stays green while logging `Having 1 errors!`.

From the run:
https://github.com/ClickHouse/ClickHouse/actions/runs/27329849519/job/80742955516?pr=106987
@Algunenano

Copy link
Copy Markdown
Member

At least locally #107033 fixes all the stack related issues, including this JIT one. I'll merge it once it's green

@leshikus

Copy link
Copy Markdown
Collaborator Author

The related problem is fixed #107033

@leshikus leshikus closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants