You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ppc64le: bundled libunwind unw_getcontext leaves callee-saved vector registers byte-swapped (fixed in LLVM main, not backported) #127366
ai_p2comp-external-dependenciesThird-party deps updates in contrib/, vendored code, and platform base libraries.externalAuthor is not a member of the ClickHouse organization
On little-endian ppc64le, unw_getcontext in contrib/llvm-project/libunwind/src/UnwindRegistersSave.S
corrupts the caller's callee-saved vector registers. PPC64_STVS(n) does xxswapd n,n; stxvd2x n,0,4 and never swaps back, so v20-v31 and f14-f31 come back
byte-swapped.
Fixed in LLVM main: llvm/llvm-project@6b0a46958c (#198371, 2026-07-25).
Not in the LLVM release/21.x, 22.x or 23.x branches, nor in ClickHouse/llvm-project
(release-22.x, clickhouse1, or the pin used by master, daf4510c). The fix is one line:
a second xxswapd n, n after the store.
Effect we saw: ClickHouse v26.8.15.10-lts cross-compiled for ppc64le (clang-22, -O3,
-mcpu=power8) failed to start in about 10-19% of runs under qemu-user: an SLP-vectorized
constant held in v28 across a stack-trace capture in SystemLogs::SystemLogs came back
swapped, a string header was read as empty, and start failed with UNKNOWN_TABLE
("Both table name and UUID are empty"). Not tested on native ppc64le hardware.
Evidence (same harness, qemu 8.2.2):
ClickHouse's UnwindRegistersSave.S in isolation: 12/12 callee-saved vector registers
corrupted; 0/12 with the fix.
120 server starts: 14 failures unpatched, 0 patched. Our CI smoke step passed 22/22
with the patch applied.
Proposed fix: backport 6b0a46958c to ClickHouse/llvm-project release-22.x (the branch master
tracks), then bump contrib/llvm-project. The backport is a clean cherry-pick (+4 lines,
identical to upstream): ClickHouse/llvm-project#142
Follow-up on why this went unnoticed: ClickHouse CI builds ppc64le (BuildTypes.PPC64LE in
ci/defs/job_configs.py, cross-compiled) but I could not find a job that runs the resulting
binary, so a bug that only shows at runtime on ppc64le would not be caught. We hit it
because our packaging pipeline starts the ppc64le server under qemu-user; there it failed
in about 10-19% of starts before we patched libunwind.
A cheap guard would be a QEMU smoke start of the ppc64le build, or a small test that calls
unw_getcontext and checks v20-v31 are unchanged. The standalone check we used is: load known
values into v20-v31, call __unw_getcontext, read them back, compare (12/12 corrupted
without the fix, 0/12 with it). I can share it if useful.
I may have missed a ppc64le test job in the CI definitions; corrections welcome.
@groeneai Please review this issue against current master. Confirm whether contrib/llvm-project (the pin master uses) still lacks llvm/llvm-project@6b0a46958c, and whether the cherry-pick in ClickHouse/llvm-project#142 is the right fix. Also say whether CI has any job that runs the ppc64le binary (not just builds it).
Master still lacks the fix.contrib/llvm-project is pinned at fa3910d6, which is the current tip of ClickHouse/release-22.x (compare: identical). Its libunwind/src/UnwindRegistersSave.S still has the LE PPC64_STVS as xxswapd n, n; stxvd2x n, 0, 4 with no swap back. The ppc64le build uses -mcpu=power8 (cmake/cpu_features.cmake), so this __VSX__ + __LITTLE_ENDIAN__ path is the one compiled. ClickHouse/release-23.x (5a736e6e), where Use clang-23 #117346 (Use clang-23) moves the pin, lacks it too.
[libunwind][PPC64] Backport: fix unw_getcontext corrupting callee-saved VSX registers on LE llvm-project#142 looks like the right fix. Its diff is identical to upstream 6b0a46958c (one xxswapd n, n after the store, plus the comment). Its base is ClickHouse/release-22.x, the branch master's pin tracks; the branch has moved since only by [msan] Keep the stack when an async signal arrives during a report llvm-project#118, which master already pins, so a bump after merging it would carry nothing else. The restore side needs no change: PPC64_LVS and PPC64_CLVS_RESTORE swap the register right after loading it, which is correct, and PPC64_STVS is the only in-place swap in the save file.
I reproduced it independently: I assembled UnwindRegistersSave.S with clang-22 (--target=powerpc64le-linux-gnu -mcpu=power8) and called __unw_getcontext from a harness that loads known values into v20-v31 and f14-f31, under qemu-ppc64le with -cpu power8, power9 and power10. At the master pin, 12/12 vector registers and 18/18 FPRs differ after the call; with the file from jsonRowOutputStream compile error #142, 0/12 and 0/18. The VS save area written to the context is byte-identical in both, so the fix changes only the live registers, not what the unwinder reads.
Merging jsonRowOutputStream compile error #142 and bumping the submodule is a maintainer's call; if master moves to release-23.x, the same cherry-pick is needed there.
No CI job runs the ppc64le binary. On master, BuildTypes.PPC64LE is only a parameter of the special build job in ci/defs/job_configs.py (cross-compiled on an ARM runner, -DENABLE_TESTS=0, provides=[ArtifactNames.CH_PPC64LE]). No job in ci/defs/job_configs.py or ci/workflows/*.py consumes CH_PPC64LE; its only other use is build_master_head_hook.py, which uploads master builds to the powerpc64le static location. The only post-build execution in ci/jobs/build_clickhouse.py is the wasm64 clickhouse local smoke under Node.js, with nothing equivalent for ppc64le, so a runtime-only ppc64le bug like this one is not caught by CI.
ai_p2comp-external-dependenciesThird-party deps updates in contrib/, vendored code, and platform base libraries.externalAuthor is not a member of the ClickHouse organization
Activity
[libunwind][PPC64] Fix unw_getcontext corrupting callee-saved VSX reg…
[libunwind][PPC64] Fix unw_getcontext corrupting callee-saved VSX reg…
jsc0218 commentedon Oct 23, 2026
Follow-up on why this went unnoticed: ClickHouse CI builds ppc64le (BuildTypes.PPC64LE in
ci/defs/job_configs.py, cross-compiled) but I could not find a job that runs the resulting
binary, so a bug that only shows at runtime on ppc64le would not be caught. We hit it
because our packaging pipeline starts the ppc64le server under qemu-user; there it failed
in about 10-19% of starts before we patched libunwind.
A cheap guard would be a QEMU smoke start of the ppc64le build, or a small test that calls
unw_getcontext and checks v20-v31 are unchanged. The standalone check we used is: load known
values into v20-v31, call __unw_getcontext, read them back, compare (12/12 corrupted
without the fix, 0/12 with it). I can share it if useful.
I may have missed a ppc64le test job in the CI definitions; corrections welcome.
PedroTadim commentedon Oct 26, 2026
Releases before 26.3 are no longer supported
jsc0218 commentedon Nov 5, 2026
@groeneai Please review this issue against current master. Confirm whether
contrib/llvm-project(the pin master uses) still lacks llvm/llvm-project@6b0a46958c, and whether the cherry-pick in ClickHouse/llvm-project#142 is the right fix. Also say whether CI has any job that runs the ppc64le binary (not just builds it).groeneai commentedon Nov 5, 2026
I checked this against current master (
bc84b09d).Master still lacks the fix.
contrib/llvm-projectis pinned atfa3910d6, which is the current tip ofClickHouse/release-22.x(compare: identical). Itslibunwind/src/UnwindRegistersSave.Sstill has the LEPPC64_STVSasxxswapd n, n; stxvd2x n, 0, 4with no swap back. The ppc64le build uses-mcpu=power8(cmake/cpu_features.cmake), so this__VSX__+__LITTLE_ENDIAN__path is the one compiled.ClickHouse/release-23.x(5a736e6e), where Useclang-23#117346 (Use clang-23) moves the pin, lacks it too.[libunwind][PPC64] Backport: fix unw_getcontext corrupting callee-saved VSX registers on LE llvm-project#142 looks like the right fix. Its diff is identical to upstream 6b0a46958c (one
xxswapd n, nafter the store, plus the comment). Its base isClickHouse/release-22.x, the branch master's pin tracks; the branch has moved since only by [msan] Keep the stack when an async signal arrives during a report llvm-project#118, which master already pins, so a bump after merging it would carry nothing else. The restore side needs no change:PPC64_LVSandPPC64_CLVS_RESTOREswap the register right after loading it, which is correct, andPPC64_STVSis the only in-place swap in the save file.I reproduced it independently: I assembled
UnwindRegistersSave.Swith clang-22 (--target=powerpc64le-linux-gnu -mcpu=power8) and called__unw_getcontextfrom a harness that loads known values into v20-v31 and f14-f31, under qemu-ppc64le with-cpu power8,power9andpower10. At the master pin, 12/12 vector registers and 18/18 FPRs differ after the call; with the file from jsonRowOutputStream compile error #142, 0/12 and 0/18. The VS save area written to the context is byte-identical in both, so the fix changes only the live registers, not what the unwinder reads.Merging jsonRowOutputStream compile error #142 and bumping the submodule is a maintainer's call; if master moves to
release-23.x, the same cherry-pick is needed there.No CI job runs the ppc64le binary. On master,
BuildTypes.PPC64LEis only a parameter of the special build job inci/defs/job_configs.py(cross-compiled on an ARM runner,-DENABLE_TESTS=0,provides=[ArtifactNames.CH_PPC64LE]). No job inci/defs/job_configs.pyorci/workflows/*.pyconsumesCH_PPC64LE; its only other use isbuild_master_head_hook.py, which uploads master builds to thepowerpc64lestatic location. The only post-build execution inci/jobs/build_clickhouse.pyis the wasm64clickhouse localsmoke under Node.js, with nothing equivalent for ppc64le, so a runtime-only ppc64le bug like this one is not caught by CI.CI: run a unw_getcontext vector-register check on the ppc64le build u…
CI: start clickhouse-server from the ppc64le build under QEMU repeatedly
CI: make the ppc64le server smoke test a standing guard
DO NOT MERGE: 30 ppc64le smoke starts to reproduce ClickHouse#127366
PedroTadim commentedon Nov 6, 2026
@jsc0218 you can now create the bump PR for the submodule
jsc0218 commentedon Nov 10, 2026
@PedroTadim I bumped here #129808, thanks for review.