[S-TIR] Fix Segfault when applying Parallel during TIR schedule rewriting#19403
[S-TIR] Fix Segfault when applying Parallel during TIR schedule rewriting#19403cchung100m wants to merge 3 commits intoapache:mainfrom
Conversation
…schedule rewriting
There was a problem hiding this comment.
Code Review
This pull request wraps the logic within the Apply method in a try-catch block to handle runtime::Error. Feedback indicates that AdjustParallelVectorize contains unsafe dereferences that could lead to segmentation faults when encountering dynamic shapes, which would not be caught by this block. Additionally, the new try-catch block is considered redundant with the caller's error handling and should include logging to avoid suppressing error messages.
src/s_tir/meta_schedule/postproc/rewrite_parallel_vectorize_unroll.cc
Outdated
Show resolved
Hide resolved
src/s_tir/meta_schedule/postproc/rewrite_parallel_vectorize_unroll.cc
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces safety checks for non-integer buffer shapes and loop extents within the AdjustParallelVectorize function, preventing potential crashes when dealing with dynamic shapes. The code now correctly identifies when contiguous memory access cannot be statically analyzed and resets the fusion count. A review comment suggests optimizing the buffer access loop by breaking early once a non-analyzable access is encountered, as the minimum fusion count is already reached.
Hi Commiters,
This PR is trying to fix issues #18424. Any suggestions would be appreciated if you are available.
Root Cause
Unsafe dynamic-shape dereferences in
AdjustParallelVectorizeThe code assumed IntImm for buffer shape / loop extent and dereferenced directly. With dynamic shapes, as() can be null, which can segfault before any try/catch handles it.Solution
Replaced unsafe
IntImmassumptions with null checks and GetLoopIntExtent(...); if contiguous analysis is not possible, conservatively disables that path instead of dereferencing null.