Skip to content

Update llvm-project to fix a data race on LLT::ExtendedLLT - #131685

Merged
Algunenano merged 4 commits into
masterfrom
bump-llvm-extended-llt-race
Nov 17, 2026
Merged

Algunenano merged 4 commits into
masterfrom
bump-llvm-extended-llt-race

Conversation

@thevar1able

@thevar1able thevar1able commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Follow-up to the clang-23 update. With LLVM 23, the AArch64TargetMachine constructor writes the process-global LLT::ExtendedLLT flag, which races with CHJIT instances created concurrently on other threads. Stress test (arm_tsan) reported it as a data race in LLT::setUseExtended. The fork now makes the flag a relaxed std::atomic<bool>, as suggested upstream.

The submodule is updated to the tip of ClickHouse/release-23.x, which also includes the Clang CFI fixes from ClickHouse/llvm-project#152, the thread_local destructor secret initialization on non-Linux platforms such as illumos (ClickHouse/llvm-project#155, ClickHouse/llvm-project#157), and an InstCombine fix for 0.0 / x folds (ClickHouse/llvm-project#156).

Related: #117346
Related: ClickHouse/llvm-project#154
Related: llvm/llvm-project#219517

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Fix a data race in the embedded LLVM when JIT compilation runs on several threads on AArch64.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/131685]

Version info

  • Merged into: 26.11.1.2538-master (included in 26.11 and later)

`AArch64TargetMachine` constructor writes the process-global `LLT::ExtendedLLT`
flag, which raced with `CHJIT` instances created concurrently on other threads
(ThreadSanitizer report in `Stress test (arm_tsan)`). The fork now makes the
flag a relaxed `std::atomic<bool>`.

The update also brings the Clang CFI fixes from the fork
(ClickHouse/llvm-project#152).

Related: ClickHouse/llvm-project#154
Related: #117346
Related: llvm/llvm-project#219517

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d740899]

Summary: ✅


AI Review

Summary

Reviewed #131685 at d740899a43dff7161d3c718fe1c4aa302deec8a2, including the underlying LLVM changes and all prior discussion. The submodule update makes LLT::ExtendedLLT atomic and includes CFI runtime fixes and a floating-point division optimization fix. No outstanding actionable findings. The previously reported illumos TLS initialization blocker is addressed by the included non-Linux getentropy initialization. No local build or tests were run.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement submodule changed At least one submodule changed in this PR. comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. labels Nov 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d740899a4 with master 55dd1ab2a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

457 object files changed (+71.11 KiB total), 0 added.

Object file Master PR Δ
contrib/compiler-rt-cmake/CMakeFiles/clang_rt_xray.dir/__/llvm-project/compiler-rt/lib/xray/xray_in… 22.65 KiB 81.36 KiB +58.71 KiB (+259.23%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

11302 translation units recompiled, 40408 s compile time in total, 11302 of them have a recent master baseline.

Symbol sizes
Binary Symbol Master PR Δ
programs/clickhouse-keeper __xray::XRayPatchedCustomEvent new 64.00 KiB +64.00 KiB
programs/clickhouse __xray::XRayPatchedTypedEvent new 64.00 KiB +64.00 KiB
programs/clickhouse __xray::XRayArgLogger new 64.00 KiB +64.00 KiB
programs/clickhouse __xray::XRayPatchedCustomEvent new 64.00 KiB +64.00 KiB
programs/clickhouse-keeper __xray::XRayPatchedTypedEvent new 64.00 KiB +64.00 KiB
programs/clickhouse-keeper __xray::XRayArgLogger new 64.00 KiB +64.00 KiB
programs/clickhouse-keeper __xray::XRayPatchedFunction new 64.00 KiB +64.00 KiB
programs/clickhouse __xray::XRayPatchedFunction new 64.00 KiB +64.00 KiB

Job report

@thevar1able

thevar1able commented Nov 14, 2026 •

Copy link
Copy Markdown
Member Author

🕵 The Performance Comparison jobs fail in check_executable_base.py. Both servers start with ASLR disabled, and the check correctly finds that the two binaries are laid out differently:

Executable base of the servers: 555555554000 555555550000

The LLVM bump brings in the XRay change from ClickHouse/llvm-project#152 ("xray: Keep the handler pointers read-only"). It puts each XRay handler pointer on its own 64 KiB page (struct alignas(65536) ProtectedHandler). Because of that, the last writable LOAD segment of the binary (.data/.bss) now has p_align 0x10000, where master's binary has 0x1000. Without ASLR, the kernel rounds its fixed load base down to the largest segment alignment, so the master binary is loaded at 0x555555554000 and this PR's binary at 0x555555550000. The segment alignments in both binaries:

Reference (master b04bc0a81e85) This PR
last RW LOAD align 0x1000 0x10000
last RW LOAD memsz 0x14d1128 0x15290b8

The bases differ by 16 KiB, so the code keeps the same alignment within 4 KiB pages; only the alignment at 16 KiB and above changes. A performance comparison cannot run for this PR, because the reference and the candidate can never be at the same address while only one of them has the 64 KiB-aligned segment.

Merging with this failure does not affect other PRs:

  • PRs are built merged into master, so after the merge both the candidate and the reference (the newest master commit with a finished official build) have the same alignment, and the check passes again.
  • An older performance reference build is never reused when the sources differ (find_performance_reference_build), and the contrib/llvm-project change makes them differ.
  • The only exception is a short window right after the merge, until the first master commit with this change has finished its official build. A PR perf run that starts in that window is compared against an older master binary and fails the same way. A rerun after that fixes it.

@alexey-milovidov

Copy link
Copy Markdown
Member

Executable base of the servers: 555555554000 555555550000

What was it for? Should we relax this?

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 The perf check that keeps Mergeable Check red here is fixed in #131889: check_executable_base.py now compares the bases after rounding them down to the largest PT_LOAD alignment of both binaries, so the 64 KiB aligned XRay segment no longer fails it, while a server started with ASLR enabled is still detected. Once it is merged, rerun the Performance Comparison (amd_release, master_head, *) jobs here (the PR is built merged with master, so they pick up the new script).

PedroTadim pushed a commit to hsusul/ClickHouse that referenced this pull request Nov 16, 2026
With ASLR disabled, the kernel loads a PIE executable at a fixed address
rounded down to the largest `p_align` of its `PT_LOAD` segments. When a
change raises that alignment in only one of the two binaries, the reference
and the candidate get different bases even though both servers were started
correctly with `setarch -R`, and `check_executable_base.py` fails the whole
`Performance Comparison` job. This happens in
ClickHouse#131685: the `llvm-project`
bump puts the XRay handler pointers on their own 64 KiB pages, so its
binary has a writable segment aligned to `0x10000` where master's has
`0x1000`, and the bases are `0x555555550000` and `0x555555554000`. Such a
pull request could never pass the check, so `Mergeable Check` stayed red.

The check exists to notice a launcher that does not disable ASLR. Compare the
bases after rounding them down to the largest segment alignment of all the
binaries (read from the program headers of `/proc/<pid>/exe`): a random base
still differs from the fixed one in the bits above any segment alignment, so
a server started with ASLR enabled is still detected.

Checked locally with two PIE binaries linked with `-z max-page-size=4096`,
one of them with a 64 KiB aligned global: the old check fails on the pair
started with `setarch -R`, the new one passes, and both fail when either
process is started with ASLR enabled.

Related: ClickHouse#131685

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano
Algunenano enabled auto-merge November 16, 2026 12:38
@thevar1able

Copy link
Copy Markdown
Member Author

What was it for? Should we relax this?

#126977

Comment thread contrib/llvm-project Resolved
alexey-milovidov and others added 2 commits November 16, 2026 21:48
… fix for illumos

Advances the submodule to the tip of `ClickHouse/release-23.x`, which
initializes the secret with `getentropy` on non-Linux platforms
(ClickHouse/llvm-project#155, ClickHouse/llvm-project#157)
and includes an `InstCombine` fix (ClickHouse/llvm-project#156).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@clickhouse-gh clickhouse-gh Bot left a comment

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.

AI review approves this commit, see the AI Review comment.

@Algunenano
Algunenano added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit d3955d6 Nov 17, 2026
194 checks passed
@Algunenano
Algunenano deleted the bump-llvm-extended-llt-race branch November 17, 2026 06:05
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants