This is an automated email from the ASF dual-hosted git repository.

HuaHuaY pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new e89273352e GH-51135: [C++][Parquet] Avoid misaligned stores when 
reading BYTE_ARRAY decimals (#51136)
e89273352e is described below

commit e89273352e5cfbc951089bf2f06172b7f26f727c
Author: Gang Wu <[email protected]>
AuthorDate: Wed Sep 2 15:21:47 2026 +0800

    GH-51135: [C++][Parquet] Avoid misaligned stores when reading BYTE_ARRAY 
decimals (#51136)
    
    ### Rationale for this change
    
    The BYTE_ARRAY decimal converter always clears 16 bytes through `uint64_t` 
stores. After Decimal32/64 support was added, Decimal32 output slots can be 
only 4-byte aligned, causing undefined behavior.
    
    ### What changes are included in this PR?
    
    Replace the fixed `uint64_t` stores with `std::memset(out_ptr, 0, 
type_length)`.
    
    ### Are these changes tested?
    
    Yes. The existing Decimal32/64/128/256 BYTE_ARRAY tests all pass. No new 
test is needed because `TestReadDecimals.Decimal32ByteArray` directly exercises 
this path.
    
    ### Are there any user-facing changes?
    
    No, this is a bug fix.
    
    AI usage: OpenAI Codex was used to investigate and draft this change. The 
patch was reviewed and tested locally.
    
    * GitHub Issue: #51135
    
    Authored-by: Gang Wu <[email protected]>
    Signed-off-by: Zehua Zou <[email protected]>
---
 cpp/src/parquet/arrow/reader_internal.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/cpp/src/parquet/arrow/reader_internal.cc 
b/cpp/src/parquet/arrow/reader_internal.cc
index 12f36fe39c..b5207aca25 100644
--- a/cpp/src/parquet/arrow/reader_internal.cc
+++ b/cpp/src/parquet/arrow/reader_internal.cc
@@ -725,9 +725,7 @@ struct DecimalConverter<DecimalArrayType, ByteArrayType> {
         return Status::Invalid("Invalid BYTE_ARRAY length for ", 
type->ToString());
       }
 
-      auto out_ptr_view = reinterpret_cast<uint64_t*>(out_ptr);
-      out_ptr_view[0] = 0;
-      out_ptr_view[1] = 0;
+      std::memset(out_ptr, 0, type_length);
 
       // only convert rows that are not null if there are nulls, or
       // all rows, if there are not

Reply via email to