CI: make-sqlite3 fails on ubuntu-latest

オープン 初心者向け
#2,320 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 11 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, github-actions
領域
ci-cd, databases

調査の方向性

まず .github/workflows/sqlite3.yml と make-sqlite3 ジョブを読みます。issue には libsql-sqlite3 で testfixture と test/libsql_vector.test を使った再現手順があります。説明に従ってジョブを ubuntu-24.04 に固定し、workflow の設定にその runner が反映されていることを確認します。issue によると、この workflow は libsql-sqlite3/** に変更があった場合にのみ実行されるため、workflow だけの変更では起動しません。

索引モデルが issue の本文から書いたものです。

説明

Current origin/main has a bug.

The make-sqlite3 job ("Makefile CI with Wasm enabled", .github/workflows/sqlite3.yml) fails on current ubuntu-latest runners, which now resolve to Ubuntu 26.04.

One test out of 330,804 fails: vector-1-conversion-f8 in test/libsql_vector.test.

Note:

This is a different job and a different cause from #2315 / #2317, and #2317 does not cover it.

  • Last green run, on ubuntu-24.04: 42522832842
  • Failing run, on ubuntu-26.04 (image 20261111.196.1): 43845107230

Symptom

One element prints as 1.63294 where 1.63295 is expected. In the same test one more value prints as 10.19 instead of 10.1899, and the f32/f64 hex of the converted vectors differs in the last bits.

Cause

The 26.04 runner image installs Ubuntu's amd64v3 packages (the job log shows tcl8.6-dev_..._amd64v3.deb). The gcc of that variant defaults to -march=x86-64-v3, which enables FMA. testfixture is built with plain gcc -g -O2, and gcc's default is -ffp-contract=fast, so this expression in vectorConvertFromF8() (libsql-sqlite3/src/vector.c) is compiled to one fused multiply-add:

dstF32[i] = alpha * src[i] + shift;

A fused multiply-add rounds once instead of twice, so the result differs in the last bit and the test's printed values change. The f8 blob itself is the same either way. Only the values decoded from it differ. Wasm and gcc 15 as such are not the cause.

How to reproduce

On any x86-64 machine with FMA, no container needed:

cd libsql-sqlite3 && mkdir bld && cd bld
CFLAGS="-g -O2 -march=x86-64-v3" ../configure && make testfixture
./testfixture ../test/libsql_vector.test     # vector-1-conversion-f8 fails

With CFLAGS="-g -O2 -march=x86-64-v3 -ffp-contract=off" the test passes.

What I checked:

  • In an ubuntu:26.04 container with APT::Architecture-Variants "amd64v3", gcc 15.2.0 reports -march=x86-64-v3 and defines __FMA__. The stock ubuntu:26.04 gcc reports -march=x86-64.
  • A testfixture built in that container with the default ./configure fails vector-1-conversion-f8, and its "got" output is byte-identical to the one in the CI log.
  • On my machine -march=x86-64-v3 gives the same output, and adding -ffp-contract=off makes the test pass.
  • In an ubuntu:24.04 container (gcc 13.3, -march=x86-64) the test passes.

Not checked: I did not inspect the gcc on the runner itself, only that its apt installs amd64v3 packages. I ran only libsql_vector.test, not the full make test, and without --enable-wasm-runtime-dynamic.

Fix to unblock CI

Pin the job to ubuntu-24.04, the same approach as #2317. It could go into #2317 or be a PR of its own:

--- a/.github/workflows/sqlite3.yml
+++ b/.github/workflows/sqlite3.yml
@@ -19,7 +19,10 @@ concurrency:
 
 jobs:
   make-sqlite3:
-    runs-on: ubuntu-latest
+    # The ubuntu-26.04 image uses amd64v3 packages, whose gcc defaults to
+    # -march=x86-64-v3. The resulting FMA contraction changes the floats
+    # expected by vector-1-conversion-f8 in test/libsql_vector.test.
+    runs-on: ubuntu-24.04
     defaults:
       run:
         working-directory: libsql-sqlite3

Note that this workflow only runs when libsql-sqlite3/** changes, so a PR with only this change will not run it.

Longer-term options

The pin hides the fact that the result of vector_extract() on an f8 vector depends on the compiler's target flags. Anyone who builds libSQL with -march=x86-64-v3, -march=native, or on a distribution whose gcc defaults to it gets the other rounding. Options, for the maintainers to choose:

  1. Build with -ffp-contract=off. That keeps today's output everywhere, but only for builds that use the flag.
  2. Make the code independent of contraction. gcc ignores #pragma STDC FP_CONTRACT, so that means something like storing the product in a volatile temporary before the addition. It costs some speed, and the bundled amalgamations need regenerating.
  3. Make the test tolerant of the last bit (round the printed values, drop the hex comparison).
主要言語
C
スター
17.3k
フォーク
562
平均マージ
10日 15時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tursodatabase/libsql のほかの issue

tursodatabase/libsql の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。