Skip to content

Commit f6b0bd0

Browse files
committed
ci: enable sanitizer
1 parent 3cf5963 commit f6b0bd0

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

.github/workflows/sanitizer_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ jobs:
5050
- name: Run Tests
5151
working-directory: build
5252
env:
53-
ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=0:detect_container_overflow=0
53+
ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=1:detect_container_overflow=0
5454
LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/lsan-suppressions.txt
55-
UBSAN_OPTIONS: log_path=out.log:halt_on_error=0:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt
55+
UBSAN_OPTIONS: log_path=out.log:halt_on_error=1:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt
5656
run: |
5757
ctest --output-on-failure
5858
- name: Save the test output

test/arrow_test.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ TEST_P(ToArrowSchemaTest, PrimitiveType) {
100100
auto metadata = field->metadata();
101101
ASSERT_TRUE(metadata->Contains(kFieldIdKey));
102102
ASSERT_EQ(metadata->Get(kFieldIdKey), std::to_string(kFieldId));
103+
104+
// Release the arrow schema to avoid memory leak
105+
if (arrow_schema.release != nullptr) {
106+
arrow_schema.release(&arrow_schema);
107+
}
103108
}
104109

105110
INSTANTIATE_TEST_SUITE_P(
@@ -188,6 +193,11 @@ TEST(ToArrowSchemaTest, StructType) {
188193
kIntFieldId));
189194
ASSERT_NO_FATAL_FAILURE(CheckArrowField(*struct_field->field(1), ::arrow::Type::STRING,
190195
kStrFieldName, /*nullable=*/true, kStrFieldId));
196+
197+
// Release the arrow schema to avoid memory leak
198+
if (arrow_schema.release != nullptr) {
199+
arrow_schema.release(&arrow_schema);
200+
}
191201
}
192202

193203
TEST(ToArrowSchemaTest, ListType) {
@@ -216,6 +226,11 @@ TEST(ToArrowSchemaTest, ListType) {
216226
ASSERT_NO_FATAL_FAILURE(CheckArrowField(*list_field->value_field(),
217227
::arrow::Type::INT64, kElemFieldName,
218228
/*nullable=*/true, kElemFieldId));
229+
230+
// Release the arrow schema to avoid memory leak
231+
if (arrow_schema.release != nullptr) {
232+
arrow_schema.release(&arrow_schema);
233+
}
219234
}
220235

221236
TEST(ToArrowSchemaTest, MapType) {
@@ -258,6 +273,11 @@ TEST(ToArrowSchemaTest, MapType) {
258273
ASSERT_NO_FATAL_FAILURE(CheckArrowField(*value_field, ::arrow::Type::INT32,
259274
kValueFieldName,
260275
/*nullable=*/true, kValueFieldId));
276+
277+
// Release the arrow schema to avoid memory leak
278+
if (arrow_schema.release != nullptr) {
279+
arrow_schema.release(&arrow_schema);
280+
}
261281
}
262282

263283
struct FromArrowSchemaParam {
@@ -293,6 +313,11 @@ TEST_P(FromArrowSchemaTest, PrimitiveType) {
293313
ASSERT_EQ(field.field_id(), kFieldId);
294314
ASSERT_EQ(field.optional(), param.optional);
295315
ASSERT_EQ(*field.type(), *param.iceberg_type);
316+
317+
// Release the exported schema to avoid memory leak
318+
if (exported_schema.release != nullptr) {
319+
exported_schema.release(&exported_schema);
320+
}
296321
}
297322

298323
INSTANTIATE_TEST_SUITE_P(
@@ -384,6 +409,11 @@ TEST(FromArrowSchemaTest, StructType) {
384409
ASSERT_EQ(str_iceberg_field.field_id(), kStrFieldId);
385410
ASSERT_TRUE(str_iceberg_field.optional());
386411
ASSERT_EQ(str_iceberg_field.type()->type_id(), TypeId::kString);
412+
413+
// Release the exported schema to avoid memory leak
414+
if (exported_schema.release != nullptr) {
415+
exported_schema.release(&exported_schema);
416+
}
387417
}
388418

389419
TEST(FromArrowSchemaTest, ListType) {
@@ -427,6 +457,11 @@ TEST(FromArrowSchemaTest, ListType) {
427457
ASSERT_EQ(element.field_id(), kElemFieldId);
428458
ASSERT_TRUE(element.optional());
429459
ASSERT_EQ(element.type()->type_id(), TypeId::kLong);
460+
461+
// Release the exported schema to avoid memory leak
462+
if (exported_schema.release != nullptr) {
463+
exported_schema.release(&exported_schema);
464+
}
430465
}
431466

432467
TEST(FromArrowSchemaTest, MapType) {
@@ -483,6 +518,11 @@ TEST(FromArrowSchemaTest, MapType) {
483518
ASSERT_EQ(value.field_id(), kValueFieldId);
484519
ASSERT_TRUE(value.optional());
485520
ASSERT_EQ(value.type()->type_id(), TypeId::kInt);
521+
522+
// Release the exported schema to avoid memory leak
523+
if (exported_schema.release != nullptr) {
524+
exported_schema.release(&exported_schema);
525+
}
486526
}
487527

488528
} // namespace iceberg

0 commit comments

Comments
 (0)