Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions cpp/src/parquet/arrow/fuzz_encoding_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ namespace {
// Just to use std::vector<T> while avoiding std::vector<bool>
using BooleanSlot = std::array<uint8_t, sizeof(bool)>;

// OOM during fuzzing is an expected soft failure; any other non-OK status
// indicates a real bug and should abort so OSS-Fuzz can report it.
Status FuzzCheckOk(const Status& st) {
if (st.IsOutOfMemory()) return st;
ARROW_CHECK_OK(st);
return Status::OK();
}
Comment thread
omertt27 marked this conversation as resolved.
Comment thread
omertt27 marked this conversation as resolved.

template <typename T>
using PoolAllocator = ::arrow::stl::allocator<T>;

Expand Down Expand Up @@ -283,7 +291,7 @@ struct TypedFuzzEncoding {
// Read as Arrow directly and use that as reference
ARROW_ASSIGN_OR_RAISE(reference_array_,
DecodeArrow(source_encoding_, encoded_data_));
ARROW_CHECK_OK(reference_array_->ValidateFull());
RETURN_NOT_OK(FuzzCheckOk(reference_array_->ValidateFull()));
} else {
ARROW_ASSIGN_OR_RAISE(reference_values_,
Decode(source_encoding_, encoded_data_, num_values_));
Expand All @@ -300,13 +308,15 @@ struct TypedFuzzEncoding {
encoder->Put(*reference_array_);
auto reencoded_buffer = encoder->FlushValues();
auto reencoded_data = reencoded_buffer->template span_as<uint8_t>();
auto array = DecodeArrow(roundtrip_encoding_, reencoded_data).ValueOrDie();
ARROW_CHECK_OK(array->ValidateFull());
ARROW_CHECK_OK(CompareAgainstReference(array));
auto array_result = DecodeArrow(roundtrip_encoding_, reencoded_data);
RETURN_NOT_OK(FuzzCheckOk(array_result.status()));
auto array = std::move(*array_result);
RETURN_NOT_OK(FuzzCheckOk(array->ValidateFull()));
Comment thread
omertt27 marked this conversation as resolved.
RETURN_NOT_OK(FuzzCheckOk(CompareAgainstReference(array)));
// Compare with reading raw values
for (const int chunk_size : chunk_sizes()) {
ARROW_CHECK_OK(RunOnDecodedChunks(roundtrip_encoding_, reencoded_data,
chunk_size, compare_chunk));
RETURN_NOT_OK(FuzzCheckOk(RunOnDecodedChunks(roundtrip_encoding_, reencoded_data,
chunk_size, compare_chunk)));
}
} else {
encoder->Put(reference_values_.data(),
Expand All @@ -315,8 +325,8 @@ struct TypedFuzzEncoding {
auto reencoded_data = reencoded_buffer->template span_as<uint8_t>();
// Vary chunk sizes
for (const int chunk_size : chunk_sizes()) {
ARROW_CHECK_OK(RunOnDecodedChunks(roundtrip_encoding_, reencoded_data,
chunk_size, compare_chunk));
RETURN_NOT_OK(FuzzCheckOk(RunOnDecodedChunks(roundtrip_encoding_, reencoded_data,
chunk_size, compare_chunk)));
}
}
END_PARQUET_CATCH_EXCEPTIONS
Expand Down