github-actions[bot] commented on code in PR #62759:
URL: https://github.com/apache/doris/pull/62759#discussion_r3131253607


##########
be/src/core/data_type_serde/data_type_decimal_serde.cpp:
##########
@@ -372,8 +372,9 @@ Status 
DataTypeDecimalSerDe<T>::read_column_from_arrow(IColumn& column,
     } else if constexpr (T == TYPE_DECIMAL256) {
         const auto* concrete_array = dynamic_cast<const 
arrow::Decimal256Array*>(arrow_array);
         for (auto value_i = start; value_i < end; ++value_i) {
-            column_data.emplace_back(
-                    *reinterpret_cast<const 
FieldType*>(concrete_array->Value(value_i)));
+            FieldType decimal_value {};
+            memcpy(&decimal_value, concrete_array->Value(value_i), 
sizeof(FieldType));

Review Comment:
   This fixes the `TYPE_DECIMAL256` unaligned read, but the sibling 
`TYPE_DECIMALV2` branch a few lines above still does `*reinterpret_cast<const 
Decimal128V2*>(concrete_array->Value(value_i))`. `arrow::DecimalArray::Value()` 
has the same raw-byte contract, so an unaligned Arrow buffer can still trigger 
UBSan/undefined behavior for DECIMALV2 imports through the same 
`read_column_from_arrow` path. Please switch that branch to the same `memcpy` 
pattern and add a DECIMALV2 misalignment test; otherwise this PR only fixes one 
instance of the bug.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to