From 331026b905942e93c9ae6d0f6c434d0614032667 Mon Sep 17 00:00:00 2001 From: Daniel Karlsson Date: Mon, 7 Sep 2026 18:46:48 +0200 Subject: [PATCH 1/4] fuzz: fix cast_real build for numeric prefix results str_to_f64 now distinguishes complete numbers from numeric prefixes, so the two-variant destructuring no longer compiles. Use the existing f64 conversion to accept all parse results, as CAST AS REAL does. Tests: cargo +nightly fuzz build --dev cast_real; six fixed inputs covering complete numbers, numeric prefixes, and invalid text with AddressSanitizer and LeakSanitizer enabled. --- fuzz/fuzz_targets/cast_real.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fuzz/fuzz_targets/cast_real.rs b/fuzz/fuzz_targets/cast_real.rs index adcb5d53e..81668828f 100644 --- a/fuzz/fuzz_targets/cast_real.rs +++ b/fuzz/fuzz_targets/cast_real.rs @@ -1,7 +1,6 @@ #![no_main] use libfuzzer_sys::{fuzz_target, Corpus}; use std::error::Error; -use turso_core::numeric::StrToF64; fn do_fuzz(text: String) -> Result> { let expected = { @@ -12,10 +11,7 @@ fn do_fuzz(text: String) -> Result> { }; let actual = turso_core::numeric::str_to_f64(&text) - .map(|v| { - let (StrToF64::Fractional(non_nan) | StrToF64::Decimal(non_nan)) = v; - f64::from(non_nan) - }) + .map(f64::from) .unwrap_or(0.0); assert_eq!(expected, actual); From 2364b99a190677fb67d215289d462a78e676a8b8 Mon Sep 17 00:00:00 2001 From: Daniel Karlsson Date: Mon, 7 Sep 2026 19:12:32 +0200 Subject: [PATCH 2/4] fuzz: update expression to current core APIs The expression target no longer builds after changes to text ownership, database opening, parameter binding, and I/O stepping. Pass owned text, select the SQLite dialect, propagate binding errors, and advance the statement's I/O through its pager. Tests: cargo +nightly fuzz build --dev expression; ten fixed inputs covering every value type and expression variant with AddressSanitizer and LeakSanitizer enabled. --- fuzz/fuzz_targets/expression.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fuzz/fuzz_targets/expression.rs b/fuzz/fuzz_targets/expression.rs index 5cc1b0583..47f6109f4 100644 --- a/fuzz/fuzz_targets/expression.rs +++ b/fuzz/fuzz_targets/expression.rs @@ -76,7 +76,7 @@ impl From for turso_core::Value { Value::Null => turso_core::Value::Null, Value::Integer(v) => turso_core::Value::from_i64(v), Value::Real(v) => turso_core::Value::from_f64(v), - Value::Text(v) => turso_core::Value::from_text(&v), + Value::Text(v) => turso_core::Value::from_text(v), Value::Blob(v) => turso_core::Value::from_blob(v.to_owned()), } } @@ -265,17 +265,23 @@ fn do_fuzz(expr: Expr) -> Result> { let found = 'value: { let io = Arc::new(turso_core::MemoryIO::new()); - let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?; + let db = turso_core::Database::open_file( + io.clone(), + ":memory:", + Arc::new(turso_core::SqliteDialect), + )?; let conn = db.connect()?; let mut stmt = conn.prepare(sql)?; for (idx, value) in expr.parameters.iter().enumerate() { - stmt.bind_at(NonZero::new(idx + 1).unwrap(), value.clone().into()) + stmt.bind_at(NonZero::new(idx + 1).unwrap(), value.clone().into())?; } loop { use turso_core::StepResult; match stmt.step()? { - StepResult::IO | StepResult::Yield | StepResult::Sleep { .. } => stmt.run_once()?, + StepResult::IO | StepResult::Yield | StepResult::Sleep { .. } => { + stmt.get_pager().io.step()? + } StepResult::Row => { let row = stmt.row().unwrap(); assert_eq!(row.len(), 1, "expr: {:?}", expr); From 7ae16931319d271d5c0087260e55fddc907c17be Mon Sep 17 00:00:00 2001 From: Daniel Karlsson Date: Mon, 7 Sep 2026 19:20:38 +0200 Subject: [PATCH 3/4] fuzz: supply the SQLite dialect when opening the schema database Database::open_file now requires an explicit dialect. Select the SQLite dialect so the schema target builds and can execute its comparisons against SQLite again. Tests: cargo +nightly fuzz build --dev schema; eight fixed inputs covering table creation, indexes, and renames. LeakSanitizer reports retained core CompletionGroup allocations during these runs; no SQL assertions failed. --- fuzz/fuzz_targets/schema.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/schema.rs b/fuzz/fuzz_targets/schema.rs index cfba54892..b26b8fd62 100644 --- a/fuzz/fuzz_targets/schema.rs +++ b/fuzz/fuzz_targets/schema.rs @@ -335,7 +335,11 @@ fn do_fuzz(Ops(ops): Ops) -> Result> { let rusqlite_conn = rusqlite::Connection::open_in_memory()?; let io = Arc::new(turso_core::MemoryIO::new()); - let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?; + let db = turso_core::Database::open_file( + io.clone(), + ":memory:", + Arc::new(turso_core::SqliteDialect), + )?; let limbo_conn = db.connect()?; for op in ops { From 6d6de17c9ae740508e043694e40e3fb8d432fecd Mon Sep 17 00:00:00 2001 From: Daniel Karlsson Date: Tue, 8 Sep 2026 19:03:35 +0200 Subject: [PATCH 4/4] ci: build all libFuzzer targets Compile every declared target before fuzzing scalar_func so API changes cannot leave inactive fuzzers broken. Keep runtime fuzz findings advisory without hiding compile failures. Tests: cargo +nightly-2025-12-17 fuzz build --dev (cargo-fuzz 0.13.0) --- .github/workflows/fuzz.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 920eb2ffc..b4cb4f4f6 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -119,8 +119,6 @@ jobs: run: cargo run -p turso_stress --locked -- --nr-threads 2 --nr-iterations 1000 libfuzzer-scalar-func: - # Allow this job to fail without failing the entire CI run - continue-on-error: true runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 15 steps: @@ -139,5 +137,8 @@ jobs: cache-on-failure: true - name: Install cargo-fuzz run: cargo install cargo-fuzz@0.13.0 + - name: Build all libFuzzer targets + run: cargo +nightly-2025-12-17 fuzz build --dev - name: Run scalar_func fuzzer + continue-on-error: true run: cargo +nightly-2025-12-17 fuzz run scalar_func -- -max_total_time=300