This is an automated email from the ASF dual-hosted git repository. kszucs pushed a commit to branch maint-6.0.x in repository https://gitbox.apache.org/repos/asf/arrow.git
commit 73f85a40793348c86352ba7ae3ddebdb31a37ede Author: Eduardo Ponce <[email protected]> AuthorDate: Sat Oct 30 14:11:06 2021 -0400 ARROW-14514: [C++][R] UBSAN error on round kernel Add base class `OptionsWrapper` to primary template of `RoundOptionsWrapper`. Closes #11573 from edponce/ARROW-14514-UBSAN-error-on-round-kernel Authored-by: Eduardo Ponce <[email protected]> Signed-off-by: David Li <[email protected]> --- cpp/src/arrow/compute/kernels/scalar_arithmetic.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc b/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc index 48a5e81..763e40e 100644 --- a/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc +++ b/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc @@ -1048,7 +1048,7 @@ struct RoundImpl<Type, RoundMode::HALF_TO_ODD> { }; // Specializations of kernel state for round kernels -template <typename> +template <typename OptionsType> struct RoundOptionsWrapper; template <> @@ -1079,10 +1079,19 @@ template <> struct RoundOptionsWrapper<RoundToMultipleOptions> : public OptionsWrapper<RoundToMultipleOptions> { using OptionsType = RoundToMultipleOptions; + using State = RoundOptionsWrapper<OptionsType>; + using OptionsWrapper::OptionsWrapper; static Result<std::unique_ptr<KernelState>> Init(KernelContext* ctx, const KernelInitArgs& args) { - ARROW_ASSIGN_OR_RAISE(auto state, OptionsWrapper<OptionsType>::Init(ctx, args)); + std::unique_ptr<State> state; + if (auto options = static_cast<const OptionsType*>(args.options)) { + state = ::arrow::internal::make_unique<State>(*options); + } else { + return Status::Invalid( + "Attempted to initialize KernelState from null FunctionOptions"); + } + auto options = Get(*state); const auto& type = *args.inputs[0].type; if (!options.multiple || !options.multiple->is_valid) {
