Under the numba backend, x[idx] and inc_subtensor(x[idx], v) with an out-of-range integer index read and write outside the array instead of raising. The C backend raises IndexError for the same graph.
import numpy as np, pytensor, pytensor.tensor as pt
x, idx = pt.vector("x"), pt.lvector("idx")
f = pytensor.function([pytensor.In(x, mutable=True), idx], pt.inc_subtensor(x[idx], 7.0), mode="NUMBA")
backing = np.zeros(12)
f(backing[:11], np.array([np.iinfo(np.int64).min]))
print(backing[11]) # 7.0: wrote one element past the end of the 11-element input
Indices 20 and -20 also return without error, while the C backend raises IndexError for all three.
Context: a Cast{int64} of a NaN float gives INT64_MIN on x86. After negative-index wraparound it stays negative, and the scatter writes one element past the end of its buffer. glibc later reports that as corrupted size vs. prev_size or double free or corruption, far from the Op that caused it.
Under the numba backend,
x[idx]andinc_subtensor(x[idx], v)with an out-of-range integer index read and write outside the array instead of raising. The C backend raisesIndexErrorfor the same graph.Indices 20 and -20 also return without error, while the C backend raises
IndexErrorfor all three.Context: a
Cast{int64}of a NaN float givesINT64_MINon x86. After negative-index wraparound it stays negative, and the scatter writes one element past the end of its buffer. glibc later reports that ascorrupted size vs. prev_sizeordouble free or corruption, far from the Op that caused it.