Skip to content

Commit 0c74a4a

Browse files
authored
Fix fuzzing setup after Scalar ordering changes and fix io fuzzer (#2098)
1 parent 43458b8 commit 0c74a4a

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

.github/workflows/fuzz.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Archive crash artifacts
3131
uses: actions/upload-artifact@v4
3232
with:
33-
name: fuzzing-crash-artifacts
33+
name: io-fuzzing-crash-artifacts
3434
path: fuzz/artifacts
3535
- name: Persist corpus
3636
shell: bash
@@ -42,8 +42,8 @@ jobs:
4242
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_FUZZ_SECRET_ACCESS_KEY }}
4343
AWS_REGION: 'us-east-1'
4444

45-
fuzz:
46-
name: 'fuzz'
45+
ops_fuzz:
46+
name: 'Array Operations Fuzz'
4747
runs-on: ubuntu-latest
4848
steps:
4949
- uses: actions/checkout@v4
@@ -66,7 +66,7 @@ jobs:
6666
- name: Archive crash artifacts
6767
uses: actions/upload-artifact@v4
6868
with:
69-
name: fuzzing-crash-artifacts
69+
name: operations-fuzzing-crash-artifacts
7070
path: fuzz/artifacts
7171
- name: Persist corpus
7272
shell: bash

fuzz/fuzz_targets/file_io.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use libfuzzer_sys::{fuzz_target, Corpus};
99
use vortex_array::array::ChunkedArray;
1010
use vortex_array::compute::{compare, Operator};
1111
use vortex_array::{ArrayDType, ArrayData, IntoArrayData, IntoArrayVariant, IntoCanonical};
12+
use vortex_dtype::Nullability;
1213
use vortex_file::{Scan, VortexOpenOptions, VortexWriteOptions};
1314
use vortex_sampling_compressor::ALL_ENCODINGS_CONTEXT;
1415

@@ -17,6 +18,10 @@ fuzz_target!(|array_data: ArrayData| -> Corpus {
1718
return Corpus::Reject;
1819
}
1920

21+
if array_data.dtype().nullability() != Nullability::NonNullable {
22+
return Corpus::Reject;
23+
}
24+
2025
let runtime = tokio::runtime::Builder::new_current_thread()
2126
.enable_all()
2227
.build()

fuzz/src/sort.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn sort_canonical_array(array: &ArrayData) -> ArrayData {
2727
)
2828
.map(|(b, v)| v.then_some(b))
2929
.collect::<Vec<_>>();
30-
sort_opt_slice(&mut opt_values);
30+
opt_values.sort();
3131
BoolArray::from_iter(opt_values).into_array()
3232
}
3333
DType::Primitive(p, _) => {
@@ -57,7 +57,7 @@ pub fn sort_canonical_array(array: &ArrayData) -> ArrayData {
5757
let mut opt_values = utf8
5858
.with_iterator(|iter| iter.map(|v| v.map(|u| u.to_vec())).collect::<Vec<_>>())
5959
.unwrap();
60-
sort_opt_slice(&mut opt_values);
60+
opt_values.sort();
6161
VarBinViewArray::from_iter(opt_values, array.dtype().clone()).into_array()
6262
}
6363
DType::Struct(..) => {
@@ -88,17 +88,7 @@ fn sort_primitive_slice<T: NativePType>(s: &mut [Option<T>]) {
8888
s.sort_by(|a, b| match (a, b) {
8989
(Some(v), Some(w)) => v.total_compare(*w),
9090
(None, None) => Ordering::Equal,
91-
(None, Some(_)) => Ordering::Greater,
92-
(Some(_), None) => Ordering::Less,
93-
});
94-
}
95-
96-
/// Reverse sorting of Option<T> such that None is last (Greatest)
97-
fn sort_opt_slice<T: Ord>(s: &mut [Option<T>]) {
98-
s.sort_by(|a, b| match (a, b) {
99-
(Some(v), Some(w)) => v.cmp(w),
100-
(None, None) => Ordering::Equal,
101-
(None, Some(_)) => Ordering::Greater,
102-
(Some(_), None) => Ordering::Less,
91+
(None, Some(_)) => Ordering::Less,
92+
(Some(_), None) => Ordering::Greater,
10393
});
10494
}

0 commit comments

Comments
 (0)