This is an automated email from the ASF dual-hosted git repository.

syfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git


The following commit(s) were added to refs/heads/main by this push:
     new 4076ef5  Workaround Segfaults and clang-tidy warnings (#297)
4076ef5 is described below

commit 4076ef57773310a9cf3d1053085517efff51a7b4
Author: Junru Shao <[email protected]>
AuthorDate: Sun Nov 30 19:13:40 2025 -0800

    Workaround Segfaults and clang-tidy warnings (#297)
    
    After merging PR #228, segfaults appear to show up on mainline,
    nightlies and new PRs, including incoming PRs after PR #293. While it's
    too early to establish a casual link between PR #228 and the segfaults,
    particularly after reviewing a quite a few times, I'd love to dedicate
    some effort trying to narrow down the scope of the potential issue.
    
    Segfaults on `main`:
    -
    
https://github.com/apache/tvm-ffi/actions/runs/19805267663/job/56738455126?pr=295#step:11:288
    -
    https://github.com/apache/tvm-ffi/actions/runs/19532442048/job/55918436762
    -
    
https://github.com/apache/tvm-ffi/actions/runs/19796601863/job/56717832596#step:8:3516
    -
    
https://github.com/apache/tvm-ffi/actions/runs/19803545351/job/56734651884#step:11:288
    
    Segfault after commenting out `test_func`
    [[link](https://github.com/junrushao/tvm-ffi/actions/runs/19804626968)]:
    -
    
https://github.com/junrushao/tvm-ffi/actions/runs/19804626968/job/56739192940
    
    No segfaults after adding GC [link]: 11 runs, no segfault
---
 include/tvm/ffi/function_details.h | 1 +
 tests/python/test_stl.py           | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/include/tvm/ffi/function_details.h 
b/include/tvm/ffi/function_details.h
index 4cd67aa..8f16340 100644
--- a/include/tvm/ffi/function_details.h
+++ b/include/tvm/ffi/function_details.h
@@ -223,6 +223,7 @@ TVM_FFI_INLINE void unpack_call(std::index_sequence<Is...>, 
const std::string* o
     *rv = R(f(ArgValueWithContext<std::tuple_element_t<Is, PackedArgs>>{args, 
Is, optional_name,
                                                                         
f_sig}...));
   }
+  // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks
 }
 
 /*!
diff --git a/tests/python/test_stl.py b/tests/python/test_stl.py
index 4d87ff2..cedc47e 100644
--- a/tests/python/test_stl.py
+++ b/tests/python/test_stl.py
@@ -14,6 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+import gc
 import pathlib
 
 import pytest
@@ -45,6 +46,8 @@ def test_stl() -> None:
         mod.test_tuple([1.5, 2.5])
     with pytest.raises(TypeError):
         mod.test_function(lambda: 0)(100)
+    gc.collect()
+    del mod
 
 
 if __name__ == "__main__":

Reply via email to