julia
be2a09c9 - Compute jl_array_len from the dims for N-d arrays (#62813)

Commit
1 day ago
Compute jl_array_len from the dims for N-d arrays (#62813) For arrays with more than one dimension `jl_array_len` returned the length of the backing `Memory`. However, N-d arrays with excess memory capacity, and even a nonzero memoryref offset, can be created by `reshape`ing a vector with spare capacity from e.g. `sizehint!` or `push!`/`popfirst!`. This made every C code path that uses `jl_array_len` observe the wrong length. Splatting such an array (the array fast path of `jl_f__apply_iterate`) and `Core.svec` produced extra, potentially uninitialized, elements, and `jl_array_copy` copied the capacity rather than the length, reading past the end of the `Memory` when the offset is nonzero. Make `jl_array_len` compute the product of the dimensions instead. Assisted-by: Claude Code (Fable 5)
Author
Parents
Loading