`repeat` on `LargeUtf8` aborts the process on a result size no allocation can satisfy
Maintainers usually reply within 1 day
@huong8373tt-beep is already working on this.
Since Nov 2, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in datafusion/functions/src/string/repeat.rs, comparing the LargeUtf8 cap in the scalar path near lines 127-128 with the array path near lines 227-228. Read test_repeat_string_array_overflow and the reproduction snippet, then choose the fixed-cap or try_reserve approach and make both paths return an error for a count of 1 << 60. Add a regression test covering scalar LargeUtf8 and the array builder, and run the repeat tests.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Rust
- Stars
- 9.6k
- Forks
- 2.6k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 331
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/datafusion
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apache/datafusion#27059 ·
Maintainers usually reply within 1 day
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsPossibly taken @joseph-isaacs claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/datafusion#27050 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/datafusion#26999 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
apache/datafusion#26998 ·
Maintainers usually reply within 1 day
-
[Bug] atan2 does not normalize -0.0 the way Spark doesPossibly taken @galaxytemple claimed this 3 days ago. Openbug spark
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/datafusion#26333 ·
Maintainers usually reply within 1 day
All issues in apache/datafusion
Similar issues
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
oxc-project/oxc#28783 ·
Maintainers usually reply within 1 day
-
Bump calamine to 0.38: RUSTSEC-2026-0436 (CFB/OLE2 panic and unbounded allocation) fails cargo auditOpen
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
docling-project/docling.rs#979 ·
Maintainers usually reply within 1 day
-
llm translation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100