Skip to content

Conversation

@tqchen
Copy link
Member

@tqchen tqchen commented Jun 7, 2025

This PR enhances the exception safety of FFI Object during init. Specifically, when an error is thrown during init before __init_by_constructor chandle can be in a undefined state. Additionally, tools like pytest may try to call repr to get a string repr the object, causing segfault.

This PR fixes the issue by always first initialize chandle to NULL and provide chandle=None special handling so pytest can be happy in such cases.

This PR enhances the exception safety of FFI Object during init.
Specifically, when an error is thrown during init before __init_by_constructor
chandle can be in a undefined state. Additionally, tools like pytest may
try to call repr to get a string repr the object, causing segfault.

This PR fixes the issue by always first initialize chandle to NULL
and provide chandle=None special handling so pytest can be happy
in such cases.
@spectrometerHBH spectrometerHBH merged commit 9cb6705 into apache:main Jun 8, 2025
13 checks passed
ShiboXing pushed a commit to ShiboXing/tvm that referenced this pull request Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants