Skip to content

Fuzzing Crash: VortexError in file_scan_expr_v2 #12531

Backlog

Description

@github-actions

Target crashed at vortex-array/src/scalar_fn/builtin/numeric/row.rs:134:numeric_error:

Failed to compute validity mask:
  integer overflow in checked sub
Stack trace
stack backtrace:
   1: core::panicking::panic_fmt
             at /rustc/8eb778d04094d3af4b26580cab327e0413eb1e02/library/core/src/panicking.rs:80:14
   2: panic_display<vortex_error::VortexError>
             at /home/runner/.rustup/toolchains/nightly-2026-11-13-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:259:5
   3: result_expect_failed<vortex_error::VortexError>
             at ./vortex-error/src/lib.rs:553:9
   4: vortex_expect<vortex_mask::Mask, vortex_error::VortexError>
             at ./vortex-error/src/lib.rs:258:25
   5: to_mask_fill_null_false<vortex_array::array::typed::Array<vortex_array::arrays::bool::vtable::Bool>>
             at ./vortex-array/src/arrays/bool/array.rs:132:14
   6: execute
             at ./vortex-functions/src/case_when/mod.rs:271:39
   7: execute_step<vortex_functions::case_when::CaseWhen>
             at ./vortex-array/src/scalar_fn/vtable.rs:242:14
   8: execute_step<vortex_functions::case_when::CaseWhen>
             at ./vortex-array/src/scalar_fn/typed.rs:198:22
   9: execute_step
             at ./vortex-array/src/scalar_fn/erased.rs:164:16
  10: execute
             at ./vortex-array/src/arrays/scalar_fn/vtable/mod.rs:155:33
  11: execute_encoding<vortex_array::arrays::scalar_fn::vtable::ScalarFn>
             at ./vortex-array/src/array/mod.rs:271:5
  12: execute_encoding_unchecked
             at ./vortex-array/src/array/erased.rs:752:9
  13: execute_until<vortex_array::canonical::AnyCanonical>
             at ./vortex-array/src/executor/mod.rs:455:40
  14: execute
             at ./vortex-array/src/canonical.rs:597:28
  15: execute<vortex_array::canonical::Canonical>
             at ./vortex-array/src/executor/mod.rs:109:9
  16: execute
             at ./vortex-array/src/canonical.rs:806:21
  17: execute<vortex_array::canonical::RecursiveCanonical>
             at ./vortex-array/src/executor/mod.rs:109:9
  18: {closure#0}<vortex_io::runtime::current::CurrentThreadIterator<core::result::Result<vortex_array::array::erased::ArrayRef, vortex_error::VortexError>>, file_scan_expr_v2::_::__libfuzzer_sys_run::{closure_env#0}>
             at ./fuzz/scan_expr.rs:89:24
  19: run<vortex_io::runtime::current::CurrentThreadIterator<core::result::Result<vortex_array::array::erased::ArrayRef, vortex_error::VortexError>>, file_scan_expr_v2::_::__libfuzzer_sys_run::{closure_env#0}>
             at ./fuzz/scan_expr.rs:93:9
  20: run_file_scan_expr<vortex_io::runtime::current::CurrentThreadIterator<core::result::Result<vortex_array::array::erased::ArrayRef, vortex_error::VortexError>>, file_scan_expr_v2::_::__libfuzzer_sys_run::{closure_env#0}>
... (29 more frames truncated)

To reproduce, download the crash artifact to ~/Downloads and run these
commands from the repository root:

unzip ~/Downloads/file_scan_expr_v2-crash-artifacts.zip -d fuzz-artifacts
RUST_BACKTRACE=1 cargo +nightly fuzz run -D --sanitizer=none \
  file_scan_expr_v2 \
  fuzz-artifacts/file_scan_expr_v2/crash-7fb791cb15cb7ed80c70c1ac839ce61d5d2f075e \
  -- -rss_limit_mb=0

Auto-created by fuzzing workflow

Activity

  1. added
    fuzzer
    bug
    on Dec 1, 2026
  2. github-actions commented on Dec 1, 2026

    @github-actions
    ContributorAuthor

    Seen 7 times

  3. github-actions commented on Dec 2, 2026

    @github-actions
    ContributorAuthor

    🤖 Fuzzer fix: ✅ succeeded

    The fix passed the fuzz-fix-review skill, and a draft pull request is open: #12559

    Run 46803940979, attempt 1 · started 2026-12-02T04:54:37Z · finished 2026-12-02T05:13:31Z

  4. vortex-claude commented on Dec 2, 2026

    @vortex-claude
    Contributor

    Root cause

    This is a library bug, not a harness bug. The harness already discards scan errors (once().ok() in fuzz/scan_expr.rs), so only a panic counts as a failure.

    The crashing projection is a CASE WHEN (no ELSE) whose condition is:

    mask(
      mask(like("\rF", "XTƟ"), between(4415723635229167453 - $, 4526861649683338564, case_when(...))),
      is_not_null(fill_null($, $)),
    )
    

    Here $ is a non-nullable i64 column. Mask::execute_canonical keeps the unexecuted mask argument as the lazy validity of its result. This is intended:

    // vortex-array/src/scalar_fn/builtin/mask/mod.rs:198
    fn execute_canonical(
        input: ArrayRef,
        mask_array: ArrayRef,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<ArrayRef> {
        let validity = child_to_validity(Some(&mask_array), Nullability::Nullable);
        let canonical = input.execute::<Canonical>(ctx)?;
        Ok(mask_validity_canonical(canonical, validity, ctx)?.into_array())
    }

    So after CaseWhen executes the condition to a BoolArray, the condition's validity still contains 4415723635229167453 - $. That checked subtraction overflows on the file's data. This is a legitimate, data-dependent error, and Validity::execute_mask returns VortexResult for that reason. BoolArrayExt::to_mask_fill_null_false then turned the error into a panic.

    Crash location

    vortex-array/src/arrays/bool/array.rs:129-132, called from vortex-functions/src/case_when/mod.rs:271:

    fn to_mask_fill_null_false(&self, ctx: &mut ExecutionCtx) -> Mask {
        let validity_mask = BoolArrayExt::validity(self)
            .execute_mask(self.len(), ctx)
            .vortex_expect("Failed to compute validity mask");
    panicked at vortex-error/src/lib.rs:553:9:
    Failed to compute validity mask:
      integer overflow in checked sub
    

    Fix

    to_mask_fill_null_false now returns VortexResult<Mask>, and the callers propagate the error.

    vortex-array/src/arrays/bool/array.rs:

        /// Convert to a [`Mask`] in which null elements are `false`.
        ///
        /// Fails if executing a lazy validity array fails.
        fn to_mask_fill_null_false(&self, ctx: &mut ExecutionCtx) -> VortexResult<Mask> {
            let validity_mask = BoolArrayExt::validity(self).execute_mask(self.len(), ctx)?;
            let buffer = match validity_mask {
                Mask::AllTrue(_) => self.to_bit_buffer(),
                Mask::AllFalse(_) => return Ok(Mask::new_false(self.len())),
                Mask::Values(validity) => validity.bit_buffer() & self.to_bit_buffer(),
            };
            Ok(Mask::from_buffer(buffer))
        }

    Call-site changes. Each one-line change is inside an existing function that already returns VortexResult:

    // vortex-functions/src/case_when/mod.rs, CaseWhen::execute
                let cond_mask = cond_bool.to_mask_fill_null_false(ctx)?;
    
    // vortex-functions/src/zip/mod.rs, Zip::execute
            let mask = mask_array
                .execute::<BoolArray>(ctx)?
                .to_mask_fill_null_false(ctx)?;
    
    // vortex-python/src/arrays/mod.rs, PyArray::filter (inside the VortexResult closure)
                let mask = mask
                    .execute::<BoolArray>(&mut ctx)?
                    .to_mask_fill_null_false(&mut ctx)?;

    Two callers keep their previous panic behaviour, with vortex_expect at the call site, matching the steps around them:

    // vortex-array/src/compute/conformance/mask.rs, test_nullable_mask_input
        let mask_array = nullable_mask
            .to_mask_fill_null_false(ctx)
            .vortex_expect("to_mask_fill_null_false should succeed in conformance test");
    
    // fuzz/fuzz_targets/file_io.rs (reference computation)
                let mask = bool_mask_bool
                    .to_mask_fill_null_false(&mut ctx)
                    .vortex_expect("mask from bool");

    API change: the return type of the public BoolArrayExt::to_mask_fill_null_false changed from Mask to VortexResult<Mask>.

    Regression test

    vortex-functions/src/case_when/tests.rs:

    /// `mask` keeps its mask argument as the lazy validity of its result, so executing a masked
    /// condition to a `BoolArray` defers the mask's computation. An overflow there must surface as an
    /// error from `CaseWhen`, not a panic.
    #[test]
    fn condition_validity_error_is_returned() -> VortexResult<()> {
        let mut ctx = SESSION.create_execution_ctx();
        let overflowing_mask = buffer![i64::MIN, 0, 1]
            .into_array()
            .numeric(buffer![1i64, 1, 1].into_array(), NumericOperator::Sub)?
            .compare(
                ConstantArray::new(0i64, 3).into_array(),
                CompareOperator::Gt,
                CompareMode::TOTAL_ORDER,
            )?;
        let condition = BoolArray::from_iter([true, false, true])
            .into_array()
            .mask(overflowing_mask)?;
    
        let case = ScalarFnArray::try_new(
            CaseWhen.bind(CaseWhenOptions {
                num_when_then_pairs: 1,
                has_else: false,
            }),
            vec![condition, ConstantArray::new(1i32, 3).into_array()],
        )?
        .into_array();
    
        let error = case.execute::<Canonical>(&mut ctx).unwrap_err();
        assert!(error.to_string().contains("overflow"), "{error}");
        Ok(())
    }

    Commands run

    Command Result
    cargo test -p vortex-functions --lib condition_validity_error_is_returned (before fix) Failed, with the same panic as the crash: Failed to compute validity mask: integer overflow in checked sub
    cargo test -p vortex-functions --lib condition_validity_error_is_returned (after fix) Passed
    cargo +nightly-2026-11-13 fuzz run --dev --sanitizer=none file_scan_expr_v2 crash-7fb791cb15cb7ed80c70c1ac839ce61d5d2f075e -- -runs=1 -rss_limit_mb=0 Exits successfully (Executed ... in 179 ms), no panic
    cargo clippy -p vortex-array -p vortex-functions -p vortex-fuzz --all-targets --all-features -- -D warnings Clean
    cargo clippy -p vortex-python --all-targets --all-features -- -D warnings Clean
    cargo +nightly-2026-11-13 fmt -p vortex-array -p vortex-functions -p vortex-python -p vortex-fuzz No changes

    I did not run the full test suites of the changed crates.

    Review

    The verdict from the fuzz-fix-review skill is approve. Suggested title: Return validity errors from CaseWhen and Zip conditions instead of panicking.

    The reviewer re-ran the crash input, the regression test, clippy and fmt, and all passed. It could not create a worktree to watch the test fail on the unfixed code. I ran the test before the fix myself: it failed with the crash's panic, as shown above.

    Findings (both nits, not addressed in this change):

    • vortex-array/src/arrays/bool/array.rs:132: the signature change to the public BoolArrayExt::to_mask_fill_null_false breaks downstream callers. A maintainer should decide whether the PR needs changelog/break.
    • The same execute_mask(...).vortex_expect("Failed to compute validity mask") pattern remains at vortex-array/src/arrays/varbin/compute/filter.rs:77 and :184, and at encodings/sparse/src/canonical.rs:607 and :808. A failing lazy validity would panic there too. The fuzz input does not reach these call sites, so they are left for a follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfuzzer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions