From 775f7813bf1b04c0a5583b6f1ae5cb83f960c268 Mon Sep 17 00:00:00 2001 From: Alexander Taepper Date: Mon, 12 Oct 2026 15:07:02 +0200 Subject: [PATCH 1/3] change macro definition to avoid intermediates result increase stack sizes --- cpp/src/arrow/result.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cpp/src/arrow/result.h b/cpp/src/arrow/result.h index 564e2848bf3a..9466256e5a45 100644 --- a/cpp/src/arrow/result.h +++ b/cpp/src/arrow/result.h @@ -465,10 +465,24 @@ class [[nodiscard]] Result : public util::EqualityComparable> { } }; +#if defined(__GNUC__) || defined(__clang__) +// For gcc and clang, we can avoid the intermediate `result_name` +// escaping the current scope by using a compiler extension. +// Otherwise, we fall back to an implementation where the intermediate +// declaration might consume additional stack space. +#define ARROW_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \ + lhs = __extension__({ \ + auto&& result_name = (rexpr); \ + ARROW_RETURN_IF_(!(result_name).ok(), (result_name).status(), \ + ARROW_STRINGIFY(rexpr)); \ + std::move(result_name).ValueUnsafe(); \ + }) +#else #define ARROW_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \ auto&& result_name = (rexpr); \ ARROW_RETURN_IF_(!(result_name).ok(), (result_name).status(), ARROW_STRINGIFY(rexpr)); \ lhs = std::move(result_name).ValueUnsafe(); +#endif #define ARROW_ASSIGN_OR_RAISE_NAME(x, y) ARROW_CONCAT(x, y) @@ -482,7 +496,7 @@ class [[nodiscard]] Result : public util::EqualityComparable> { /// ValueType value; /// ARROW_ASSIGN_OR_RAISE(value, MaybeGetValue(arg)); /// -/// WARNING: ARROW_ASSIGN_OR_RAISE expands into multiple statements; +/// WARNING: ARROW_ASSIGN_OR_RAISE may expand into multiple statements; /// it cannot be used in a single statement (e.g. as the body of an if /// statement without {})! /// From 6d8b2ae48aa1f26f7129f14bed94ba09e5c1d766 Mon Sep 17 00:00:00 2001 From: Alexander Taepper Date: Mon, 12 Oct 2026 15:26:13 +0200 Subject: [PATCH 2/3] fix consumer --- cpp/src/arrow/dataset/file_ipc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/dataset/file_ipc.cc b/cpp/src/arrow/dataset/file_ipc.cc index 8e19b2bbee2a..da427a450d57 100644 --- a/cpp/src/arrow/dataset/file_ipc.cc +++ b/cpp/src/arrow/dataset/file_ipc.cc @@ -145,9 +145,9 @@ Result IpcFileFormat::ScanBatchesAsync( auto reopen_reader = [self, options, source](std::shared_ptr reader) -> Future> { - ARROW_ASSIGN_OR_RAISE(auto options, + ARROW_ASSIGN_OR_RAISE(auto read_options, GetReadOptions(*reader->schema(), *self, *options)); - return OpenReader(source, options); + return OpenReader(source, read_options); }; auto readahead_level = options->batch_readahead; auto default_fragment_scan_options = this->default_fragment_scan_options; From f96d9fa622d5564f35bb34d73b26e2d0e856e5e7 Mon Sep 17 00:00:00 2001 From: Alexander Taepper Date: Mon, 12 Oct 2026 16:35:10 +0200 Subject: [PATCH 3/3] fix formatting --- cpp/src/arrow/result.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cpp/src/arrow/result.h b/cpp/src/arrow/result.h index 9466256e5a45..449b5e3bf393 100644 --- a/cpp/src/arrow/result.h +++ b/cpp/src/arrow/result.h @@ -466,22 +466,23 @@ class [[nodiscard]] Result : public util::EqualityComparable> { }; #if defined(__GNUC__) || defined(__clang__) -// For gcc and clang, we can avoid the intermediate `result_name` +// For gcc and clang, we can avoid the intermediate `result_name` // escaping the current scope by using a compiler extension. // Otherwise, we fall back to an implementation where the intermediate // declaration might consume additional stack space. -#define ARROW_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \ - lhs = __extension__({ \ +# define ARROW_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \ + lhs = __extension__({ \ + auto&& result_name = (rexpr); \ + ARROW_RETURN_IF_(!(result_name).ok(), (result_name).status(), \ + ARROW_STRINGIFY(rexpr)); \ + std::move(result_name).ValueUnsafe(); \ + }) +#else +# define ARROW_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \ auto&& result_name = (rexpr); \ ARROW_RETURN_IF_(!(result_name).ok(), (result_name).status(), \ ARROW_STRINGIFY(rexpr)); \ - std::move(result_name).ValueUnsafe(); \ - }) -#else -#define ARROW_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \ - auto&& result_name = (rexpr); \ - ARROW_RETURN_IF_(!(result_name).ok(), (result_name).status(), ARROW_STRINGIFY(rexpr)); \ - lhs = std::move(result_name).ValueUnsafe(); + lhs = std::move(result_name).ValueUnsafe(); #endif #define ARROW_ASSIGN_OR_RAISE_NAME(x, y) ARROW_CONCAT(x, y)