`repeat` on `LargeUtf8` aborts the process on a result size no allocation can satisfy
I maintainer di solito rispondono entro 1 giorno
@huong8373tt-beep ci sta già lavorando.
Dal 2/11/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia in datafusion/functions/src/string/repeat.rs, confrontando il limite LargeUtf8 nel percorso scalare vicino alle righe 127-128 con quello del percorso array vicino alle righe 227-228. Leggi test_repeat_string_array_overflow e lo snippet di riproduzione, quindi scegli l'approccio con limite fisso o try_reserve e fai in modo che entrambi i percorsi restituiscano un errore per un conteggio di 1 << 60. Aggiungi un test di regressione che copra lo LargeUtf8 scalare e il builder di array, ed esegui i test di repeat.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Rust
- Stelle
- 9.6k
- Fork
- 2.6k
- Merge medio
- 3g 19h
- PR unite (30g)
- 326
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/datafusion
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/datafusion#27094 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlForse già presa @jonasHanhan l’ha presa 1 giorno fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/datafusion#27059 ·
I maintainer di solito rispondono entro 1 giorno
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsForse già presa @joseph-isaacs l’ha presa 2 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/datafusion#27050 ·
I maintainer di solito rispondono entro 1 giorno
-
physical-plan: decoding an Unnest or Explain node with an unset field panicsForse già presa @geoHeil l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/datafusion#26999 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
datafusion-proto: decoding an AvroScan node without the avro feature panicsForse già presa @geoHeil l’ha presa 1 giorno fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
apache/datafusion#26998 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/datafusion
Issue simili
-
bug priority: low ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
storytold/gridcraft#3446 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
seabeectl verify exits 0 when verification failsForse già presa @theyottaboy l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NationalSecurityAgency/seabee#73 ·
I maintainer di solito rispondono entro 4 giorni
-
ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
neilsh/stunt-reel#220 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno