Repository navigation
Use an 8 MiB thread stack on Darwin to avoid stack overflow in JIT codegen - #107033
Merged
Algunenano merged 3 commits intoJun 11, 2026
Merged
Conversation
Contributor
|
Workflow [PR], commit [dae1e25] Summary: ✅
AI ReviewSummaryThis PR changes Darwin worker-thread creation so PR Metadata
Missing context / blind spots
Findings
Final VerdictStatus: ✅ Approve No code changes required from this review; the changelog category should be corrected before merge. |
1 task
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 41/41 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 3 line(s) · Uncovered code |
Algunenano
enabled auto-merge
June 11, 2026 10:20
Merged
via the queue into
ClickHouse:master
with commit Jun 11, 2026
4c8f6de
326 of 328 checks passed
1 task
alexey-milovidov
added a commit
that referenced
this pull request
Jun 13, 2026
…in `Server::main` Master now sizes connection-pool thread stacks with `DEFAULT_THREAD_STACK_SIZE` (8 MiB on Darwin, where the OS default of 512 KiB is too small for JIT codegen) — see #107033. The listener pool in `clickhouse-local` mirrors the pool configuration of `Server::main`, so apply the same stack size here. Co-Authored-By: Claude Fable 5 <[email protected]>
1 task
This was referenced Nov 3, 2026
wilkermichael
pushed a commit
to Shopify/ClickHouse
that referenced
this pull request
Nov 3, 2026
For `LocalConnection` (interactive `clickhouse-local`) the whole suggestion
query runs in-process in `Suggest::loading_thread`: analyzer, planner, and the
regexp JIT that `extractAll(word, '[\\w_]{2,}')` triggers during header
evaluation. The thread was a plain `std::thread`, which macOS gives a 512 KiB
stack, and LLVM codegen does not cooperate with `checkStackSize`, so it ran
into the guard page (`EXC_BAD_ACCESS "Thread stack size exceeded"` in thread
`Suggest`). This killed the `clickhouse-local` under test in
`Fast test (arm_darwin)` for `05024_local_listener_survives_handler_exception`
(curl rc 56) and `04892_client_dialect_command` (`spawn id not open`) on
PRs ClickHouse#95355, ClickHouse#88234, ClickHouse#117004 and ClickHouse#117636: 26 of 26 macOS crash reports of those
jobs show this stack.
ClickHouse#107033 gave the global thread pool and the server pools
`DEFAULT_THREAD_STACK_SIZE` via `ThreadWithStackSize`, and 3510173 did
the same for the `clickhouse-local` listener pool; the suggestion loader was
missed. Use `ThreadWithStackSize` for it on Darwin; other platforms keep
`std::thread`, whose default stack follows `RLIMIT_STACK`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On
macOS(Darwin), secondary threads get only a 512 KiB stack by default, whereas on Linux the default followsRLIMIT_STACK(usually 8 MiB). That is too small for some deep call stacks: in particular, recursive scalar-subquery analysis that triggers LLVM JIT codegen. JIT codegen is stack-hungry and does not cooperate withcheckStackSize, so it walks straight off the end into the guard page and the server dies (only visible onarm_darwin).The crash surfaces in
.ipsreports withSIGILLand theasinotelibsystem_c.dylib: crashed on child side of fork pre-exec. That note is a red herring: it is a generic annotationmacOSattaches to any crash in a process that has forked withoutexec(the watchdog child), not a cause. The crash reproduces with the watchdog disabled too. The real fault is a stack overflow insideAArch64AsmPrinter::emitEndOfAsmFileduringCHJITcompilation.Fix: on Darwin, create our worker threads with an 8 MiB stack, matching the typical Linux default, at the two thread-creation mechanisms that matter:
std::thread-compatible wrapper (std::threadoffers no way to set the stack size);server_poolused for connection handlers.This also lets us drop the Darwin-specific, more-frequent
checkStackSizein the parser added in #102645, since the larger stack restores Linux-equivalent headroom.Linux behavior is unchanged.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106340&sha=b121002f9ec1230c7618d546e1908ed0f54d534e&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29%20%5B4%5D
Related: #103235
Related: #105921
Closes #107175
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Use a larger (8 MiB) thread stack on macOS to match the Linux default, fixing rare server crashes from stack overflow during JIT compilation.
Improvement since Darwin has never been production ready
Version info
26.6.1.637