Open jikechao opened 2 weeks ago
@Lunderberg @tqchen @Hzfengsy @junrushao
Hi all, I encountered a Segmentation Fault error while running inference on IRs containing an IF-Else
structure. Since Segfaults are typically high-priority bugs, could you please assist me in investigating this issue? Thank you!
Looks like this is a bug in the StaticPlanBlockMemory
pass. Printing out the module before and after this pass, the example has the following main
function.
Prior to StaticPlanBlockMemory
, the allocations in the if and else branches are independent. Afterwards, both branches refer to the same storage
and storage1
objects, even though these objects have only been defined in the if branch.
Investigating to see if there's a clear cause for this.
After looking into it, it looks like there may be some larger fixes required. Currently, the StaticPlanBlockMemory
pass does have some handling of relax::If
nodes in the StorageAllocatorInit
, but the StorageAllocator
itself assumes that an allocation prior to the first usage will be valid in all later usages.
I've put together a few unit tests to experiment with it (in this dev branch). Depending on which expressions are moved into the conditional, it either results in out-of-scope access of the R.memory.alloc_storage
result, or extra allocations.
@Lunderberg Thanks for your deep investigation and the fixing plan.
Actual behavior
Steps to reproduce
cc @junrushao