diff --git a/test/src/unit-enumerations.cc b/test/src/unit-enumerations.cc index e35cbc30d12..15d874c31fa 100644 --- a/test/src/unit-enumerations.cc +++ b/test/src/unit-enumerations.cc @@ -1452,6 +1452,18 @@ TEST_CASE_METHOD( REQUIRE_THROWS_WITH(schema->check(cfg_), matcher); } +TEST_CASE_METHOD( + EnumerationFx, + "ArraySchema - No Segfault on Check", + "[enumeration][array-scehma][size-check]") { + create_array(); + auto array = get_array(QueryType::READ); + auto schema = array->array_schema_latest_ptr(); + // Schema has unloaded enumerations at this point. Make sure that check + // doesn't segfault. + REQUIRE_NOTHROW(schema->check(cfg_)); +} + TEST_CASE_METHOD( EnumerationFx, "ArraySchema - Many Large Enumerations", diff --git a/tiledb/sm/array_schema/array_schema.cc b/tiledb/sm/array_schema/array_schema.cc index f35ced27396..e5bee621663 100644 --- a/tiledb/sm/array_schema/array_schema.cc +++ b/tiledb/sm/array_schema/array_schema.cc @@ -586,6 +586,12 @@ void ArraySchema::check_enumerations(const Config& cfg) const { uint64_t total_size = 0; for (const auto& pair : enumeration_map_) { + if (!pair.second) { + // We don't have an Array instance at this point so the best we can do + // is just avoid segfaulting when we attempt to check with unloaded + // enumerations. + continue; + } uint64_t size = pair.second->data().size() + pair.second->offsets().size(); if (size > max_size.value()) { throw ArraySchemaException(