Skip to content

Commit 8bc5761

Browse files
committed
fix: use 8-byte aligned buffer in SparkUnsafeRow Miri test
The test_append_null_struct_field_to_struct_builder test used a plain [u8; 16] stack buffer with no alignment guarantee. Since is_null_at performs aligned i64 reads, Miri flags this as undefined behavior when the buffer lands at a non-8-byte-aligned address. Wrap the buffer in a #[repr(align(8))] struct to match the alignment that real Spark UnsafeRow data always has from JVM memory.
1 parent c59b81b commit 8bc5761

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • native/core/src/execution/shuffle/spark_unsafe

native/core/src/execution/shuffle/spark_unsafe/row.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,9 +1687,12 @@ mod test {
16871687
let mut row = SparkUnsafeRow::new_with_num_fields(1);
16881688
// 8 bytes null bitset + 8 bytes field value = 16 bytes
16891689
// Set bit 0 in the null bitset to mark field 0 as null
1690-
let mut data = [0u8; 16];
1691-
data[0] = 1;
1692-
row.point_to_slice(&data);
1690+
// Use aligned buffer to match real Spark UnsafeRow layout (8-byte aligned)
1691+
#[repr(align(8))]
1692+
struct Aligned([u8; 16]);
1693+
let mut data = Aligned([0u8; 16]);
1694+
data.0[0] = 1;
1695+
row.point_to_slice(&data.0);
16931696
append_field(&data_type, &mut struct_builder, &row, 0).expect("append field");
16941697
struct_builder.append_null();
16951698
let struct_array = struct_builder.finish();

0 commit comments

Comments
 (0)