[Bug][TIR] `s_tir.Schedule.cache_read` omits domain bounds predicate on shifted conditional reads, causing negative-index heap buffer underflow (`SIGABRT`/`SIGSEGV`)
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 57/100
Direzione di ricerca
Start in src/s_tir/schedule/primitive/cache_read_write.cc, in MakeCacheStage, and compare its cache block predicate with predicate generation in ComputeAt. Use the supplied reproduction to inspect the scheduled B_local block and confirm the missing bounds predicate causes the negative index. Done means the cache copy preserves bounds safety and the reproduction exits successfully with the expected results.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Expected behavior
Applying valid S-TIR primitives (split, compute_at, cache_read) to a producer-consumer PrimFunc where the consumer conditionally reads a shifted index (T.if_then_else(4 <= v0, B[v0 - 4, v1], A[v0, v1])) must preserve bounds safety and produce identical results (sum=12288.0, exit code 0).
Actual behavior
s_tir.Schedule.cache_read generates an unguarded B_local cache-copy block with v0 = T.axis.spatial(2, ax0 - 4 + ax0_1) and predicate = true (missing T.where(4 <= ax0)), even though the adjacent compute_at producer block in the same loop correctly carries T.where(4 <= ax0).
After CompactBufferAllocation, B and B_local are compacted to (1024,) and unconditionally accessed at negative indices -4096..-1 for ax0 in 0..3:
B_local[ax0 * 1024 + ax1 - T.max(0, ax0 - 4) * 1024 - 4096] = B[...]
At runtime this underflows the heap allocation, corrupting TVM's WorkspacePool and glibc heap metadata and crashing with SIGABRT (corrupted double-linked list / double free or corruption (out)) or SIGSEGV depending on heap layout.
Environment
- TVM:
0.27.0(7b5acb32bd271342a24130f4ef439ff6c2e52c6c) - Upstream status: verified still unfixed on
apache/tvmmain(84657c01e5d3672cfd299bd3d5c77bff3888a1a9, 2026-12-02) - OS: Linux x86_64
Steps to reproduce
import numpy as np
import tvm
from tvm import s_tir
from tvm.script import tirx as T
@T.prim_func(s_tir=True)
def slice_then_concat(
X: T.Buffer((T.int64(5), T.int64(2048)), "float32"),
A: T.Buffer((T.int64(4), T.int64(2048)), "float32"),
C: T.Buffer((T.int64(6), T.int64(2048)), "float32"),
):
B = T.sblock_alloc_buffer((T.int64(2), T.int64(2048)), "float32")
for ax0, ax1 in T.grid(T.int64(2), T.int64(2048)):
with T.sblock("slice"):
v0, v1 = T.axis.remap("SS", [ax0, ax1])
B[v0, v1] = X[v0 + T.int64(3), v1]
for ax0, ax1 in T.grid(T.int64(6), T.int64(2048)):
with T.sblock("concat"):
v0, v1 = T.axis.remap("SS", [ax0, ax1])
C[v0, v1] = T.if_then_else(T.int64(4) <= v0, B[v0 - T.int64(4), v1], A[v0, v1])
sch = s_tir.Schedule(slice_then_concat)
blk_s = sch.get_sblock("slice")
blk_c = sch.get_sblock("concat")
_, l1 = sch.get_loops(blk_c)
l1_o, _ = sch.split(l1, factors=[None, 1024])
sch.compute_at(blk_s, l1_o, preserve_unit_loops=True)
sch.cache_read(blk_c, 0, "local")
f = tvm.compile(sch.mod, target="llvm")
f(
tvm.runtime.tensor(np.ones((5, 2048), "float32")),
tvm.runtime.tensor(np.ones((4, 2048), "float32")),
tvm.runtime.tensor(np.zeros((6, 2048), "float32")),
)
# Crashes with SIGABRT (e.g. corrupted double-linked list / double free or corruption) or SIGSEGV
Suggested fix
In src/s_tir/schedule/primitive/cache_read_write.cc (MakeCacheStage), derive the SBlockRealize predicate from the domain bounds of each cache block iter var (0 <= iter_value < dom->extent, matching compute_at / ComputeAt predicate generation) rather than hardcoding IntImm::Bool(true).
- Lingua principale
- Python
- Stelle
- 13.9k
- Fork
- 4.1k
- Merge medio
- 4g 22h
- PR unite (30g)
- 22
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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/tvm
-
[Bug] [Relax] `relax.op.unique(return_inverse=True)` returns an input-shaped inverse for N-D input when `axis` is NoneForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
[Bug][TOPI] `topi.scanop` (`cumsum` / `cumprod`) performs out-of-bounds write/read on empty tensorsApertaneeds-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 3 giorni
-
[Bug] [Relax] take_backward does not normalize negative axis causing heap OOB write and wrong gradientsForse già presa @pierceluu10 l’ha presa 4 giorni fa. Apertaneeds-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 3 giorni
-
[Bug][Relax][ONNX] NonZero returns the wrong output shape for scalar inputsForse già presa @tandede l’ha presa 9 giorni fa. Apertaneeds-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 3 giorni
-
needs-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/tvm#21043 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
Issue simili
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
web-push-libs/pywebpush#216 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AgriciDaniel/claude-seo#572 ·
I maintainer di solito rispondono entro 5 giorni
-
area:print-dispatch
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
area: docs domain: technical-writing good first issue type: documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
Deepak3699/Ai_Mentor#919 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno