junrushao opened a new pull request, #493:
URL: https://github.com/apache/tvm-ffi/pull/493

   ## Summary
   
   Add a regression test for the `register_object` `__init__` wiring that 
prevents a NULL-handle segfault.
   
   ## Root Cause
   
   `CObject` (Cython extension type) has a custom `tp_new`, so CPython's 
`object.__init__` silently ignores extra positional arguments. Before 
`_install_init` was wired into `register_object` (#491), calling 
`TestIntPair(1, 2)` fell through to `object.__init__`, producing `chandle = 
NULL`. Any subsequent field access (e.g. `pair.a`) dereferences `chandle + 
field_offset` → **segfault**.
   
   ## Test Coverage
   
   The new `test_register_object_wires_init` verifies:
   
   1. Construction via the wired `__init__` yields a live (non-NULL) handle 
with correct field values.
   2. `__new__` alone leaves `chandle` at 0, confirming `__init__` is the only 
path that creates the C++ object.
   
   The test does not exercise the actual segfault (which would crash the 
runner); the NULL-handle assertion is the safe proxy.
   
   ## Test Plan
   
   - [x] `pytest -xvs 
tests/python/test_object.py::test_register_object_wires_init` — passed
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to