Skip to content

[C++][Parquet] Avoid misaligned stores when reading BYTE_ARRAY decimals #51135

Description

@wgtmac

Describe the bug, including details regarding any error messages, version, and platform.

Describe the bug

Reading BYTE_ARRAY-backed Decimal32 values can trigger UBSan:

runtime error: store to misaligned address for type 'uint64_t'

The converter always writes two uint64_t values, even when the destination is Decimal32 (4 bytes) or Decimal64 (8 bytes):

auto out_ptr_view = reinterpret_cast<uint64_t*>(out_ptr);
out_ptr_view[0] = 0;
out_ptr_view[1] = 0;

This became reachable for Decimal32/64 after GH-44345 / PR #47427.

The stores should be replaced with:

std::memset(out_ptr, 0, type_length);

The existing TestReadDecimals.Decimal32ByteArray test reproduces it when alignment sanitization is enabled.

Component(s)

C++, Parquet

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions