Blosc / c-blosc2

A fast, compressed, persistent binary data store library for C.
https://www.blosc.org
Other
424 stars 81 forks source link

blosc_getitem return value seems inconsistent (DeepState fuzzing) #93

Open agroce opened 4 years ago

agroce commented 4 years ago

Whether I assert that it is the #bytes of the #items, some tests seem to violate the claim. Is this known/expected?

          unsigned start_item = DeepState_UIntInRange(0, num_elements-1);
          unsigned num_items = DeepState_UIntInRange(0, num_elements-start_item);
          LOG(TRACE) << "Getting " << num_items << " from " << start_item;
          int get_result = blosc_getitem(intermediate, start_item, num_items, items);
          //ASSERT_EQ(get_result, num_items * type_size) <<
          //"Getting " << num_items << " from " << start_item << " expected: " << num_items * type_size << ": got " << get_result;

If I allow either:

             ASSERT((get_result == num_items) || (get_result == (num_items * type_size))) <<
                "Getting " << num_items << " from " << start_item << " with size " << type_size << ": got " << get_result;

it never fails, but that's not a consistent API. I can minimize a failing example, if you can clarify which is the expected return value.

agroce commented 4 years ago

Looks like this is also due to type_size limit being 255; maybe should fail if parameter is too big?

FrancescAlted commented 4 years ago

Ditto in #92. But I see your point, by silently reducing typesize to 1 we are creating inconsistencies in the API. Hmm, probably failing would be better than just documenting this; I need to think a bit more on this. Anyway, thanks for bringing this to our attention.