Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #46847 to 22.8: Fix MSan report in maxIntersections function #46879

Merged
merged 1 commit into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/AggregateFunctions/AggregateFunctionMaxIntersections.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,16 @@ class AggregateFunctionIntersectionsMax final
const auto & value = this->data(place).value;
size_t size = value.size();
writeVarUInt(size, buf);
buf.write(reinterpret_cast<const char *>(value.data()), size * sizeof(value[0]));

for (size_t i = 0; i < size; ++i)
{
/// In this version, pairs were serialized with padding.
/// We must ensure that padding bytes are zero-filled.
char bytes[sizeof(value[0])]{};
unalignedStore<PointType>(&bytes[offsetof(typename MaxIntersectionsData<PointType>::Value, first)], value[i].first);
unalignedStore<Int64>(&bytes[offsetof(typename MaxIntersectionsData<PointType>::Value, second)], value[i].second);
buf.write(bytes, sizeof(value[0]));
}
}

void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena * arena) const override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
04010000000000000001000000000000000300000000000000FFFFFFFFFFFFFFFF030000000000000001000000000000000500000000000000FFFFFFFFFFFFFFFF
1 change: 1 addition & 0 deletions tests/queries/0_stateless/02670_max_intersections.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT hex(maxIntersectionsState(*)) FROM VALUES((1, 3), (3, 5));