`repeat` on `LargeUtf8` aborts the process on a result size no allocation can satisfy
Maintainer thường phản hồi trong vòng 1 ngày
@huong8373tt-beep đang làm issue này rồi.
Từ ngày 2/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Bắt đầu trong datafusion/functions/src/string/repeat.rs, so sánh giới hạn LargeUtf8 ở đường dẫn scalar gần dòng 127-128 với đường dẫn mảng gần dòng 227-228. Đọc test_repeat_string_array_overflow và đoạn mã tái hiện, sau đó chọn cách giới hạn cố định hoặc try_reserve và khiến cả hai đường dẫn trả về lỗi cho count là 1 << 60. Thêm một bài kiểm thử hồi quy bao phủ LargeUtf8 scalar và trình tạo mảng, rồi chạy các bài kiểm thử repeat.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
repeat on LargeUtf8 aborts the process on a result size no allocation can satisfy
Describe the bug
repeat caps the result at i32::MAX bytes for Utf8 and Utf8View, and returns an error above that. For LargeUtf8 the cap is i64::MAX, in both the scalar path and the array path. That cap admits sizes no allocation can satisfy. A result of 2^60 bytes (1 EiB) is larger than the virtual address space of x86_64 (48 or 57 bits) and aarch64 (at most 52 bits), so the allocator refuses it at once, whatever memory the machine has:
- With both arguments scalar,
s.repeat(count)cannot fail gracefully, so the refused allocation aborts the process:memory allocation of 1152921504606846976 bytes failed. - With an array of strings, the builder panics:
failed to allocate memory for layout Layout { size: 1152921504606846976, align: 64 (1 << 6) }.
The existing test_repeat_string_array_overflow uses a count of i64::MAX, which the overflow check catches before any allocation.
To Reproduce
On main at 926901f90:
use std::sync::Arc;
use arrow::datatypes::Field;
use datafusion_common::ScalarValue;
use datafusion_common::config::ConfigOptions;
use datafusion_expr::{ColumnarValue, ReturnFieldArgs, ScalarFunctionArgs};
use datafusion_functions::string::repeat;
let udf = repeat();
let s = ScalarValue::LargeUtf8(Some("a".to_string()));
// With ScalarValue::Utf8: Err(Execution("string size overflow on repeat, max size is 2147483647, but got 1152921504606846976"))
let n = ScalarValue::Int64(Some(1 << 60));
let arg_fields = vec![
Arc::new(Field::new("s", s.data_type(), true)),
Arc::new(Field::new("n", n.data_type(), true)),
];
let return_field = udf
.return_field_from_args(ReturnFieldArgs {
arg_fields: &arg_fields,
scalar_arguments: &[Some(&s), Some(&n)],
})
.unwrap();
let result = udf.invoke_with_args(ScalarFunctionArgs {
args: vec![ColumnarValue::Scalar(s), ColumnarValue::Scalar(n)],
arg_fields,
number_rows: 1,
return_field,
config_options: Arc::new(ConfigOptions::default()),
});
// aborts: memory allocation of 1152921504606846976 bytes failed
Expected behavior
An error, as for Utf8, instead of an abort. Two fixes seem possible:
- A fixed cap for
LargeUtf8. PostgreSQL'srepeatreturns "requested length too large" aboveMaxAllocSize, 1 GB minus 1 (oracle_compat.c). DuckDB's strings are limited tou32::MAXbytes (MAX_STRING_SIZE). - Fallible allocation, such as
try_reserve, so that a refused allocation becomes an error.
Which one should repeat use? Neither guards against an allocation that succeeds under overcommit and fails later when the pages are touched. Both turn this case, where the allocator refuses up front, into an error. #22688 tracks checked size accounting for string builders in general.
Additional context
Found by property-based tests that call each function with generated arguments, including large counts.
Willingness to contribute
I cannot contribute a fix for this bug at this time
- Ngôn ngữ chính
- Rust
- Star
- 9.6k
- Fork
- 2.6k
- Merge trung bình
- 4 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 319
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/datafusion
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apache/datafusion#26999 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
apache/datafusion#26998 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] atan2 does not normalize -0.0 the way Spark doesCó thể đã có người làm @galaxytemple đã nhận 3 ngày trước. Đang mởbug spark
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/datafusion#26333 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Unparser turns NULL list literals into `[]` and fails on NULL struct/map literalsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug help wanted unparser
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/datafusion#26316 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Struct union type coercion takes field nullability from the wrong field when field order differsCó thể làm lại được @med9110 đã nhận 19 ngày trước và không có pull request nào đang mở. Đang mởbug help wanted logical-expr tech debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/datafusion#26296 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/datafusion
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
test(hydro_std): track_membership join and leave are untestedCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
hydro-project/hydro#3289 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
diagram-bug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
enhapu-afk/omaspec#4 ·
-
priority: low ☕️ type: bug 🐛
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 4 ngày