New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stack overflow when partially-__init__ Node raises exception. #7481
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* If a Node subclass raises an exception and ctypes is in use before __init_handle_by_constructor__ is called (or self.handle is otherwise set), a Python stack overflow could result. This is because the unset handle slot causes self.handle accesses to fallback on the getattr(self, 'handle') method, invoking NodeGetAttr. * Then I believe this causes an infinite loop. * The fix is to make Node.__getattr__ raise AttributeError for all attributes in __slots__, then make __del__ tolerant to missing self.handle. * I don't believe cython is affected because it implements a descriptor to access its underlying chandle and that shouldn't be unset.
rkimball
approved these changes
Feb 19, 2021
tqchen
approved these changes
Feb 20, 2021
junrushao
approved these changes
Feb 20, 2021
junrushao
reviewed
Feb 20, 2021
Lokiiiiii
pushed a commit
to Lokiiiiii/tvm
that referenced
this pull request
Mar 2, 2021
…ache#7481) * Fix stack overflow when partially-__init__ Node raises exception. * If a Node subclass raises an exception and ctypes is in use before __init_handle_by_constructor__ is called (or self.handle is otherwise set), a Python stack overflow could result. This is because the unset handle slot causes self.handle accesses to fallback on the getattr(self, 'handle') method, invoking NodeGetAttr. * Then I believe this causes an infinite loop. * The fix is to make Node.__getattr__ raise AttributeError for all attributes in __slots__, then make __del__ tolerant to missing self.handle. * I don't believe cython is affected because it implements a descriptor to access its underlying chandle and that shouldn't be unset. * black format * actually use handle instead of self.handle
trevor-m
pushed a commit
to neo-ai/tvm
that referenced
this pull request
Mar 2, 2021
…ache#7481) * Fix stack overflow when partially-__init__ Node raises exception. * If a Node subclass raises an exception and ctypes is in use before __init_handle_by_constructor__ is called (or self.handle is otherwise set), a Python stack overflow could result. This is because the unset handle slot causes self.handle accesses to fallback on the getattr(self, 'handle') method, invoking NodeGetAttr. * Then I believe this causes an infinite loop. * The fix is to make Node.__getattr__ raise AttributeError for all attributes in __slots__, then make __del__ tolerant to missing self.handle. * I don't believe cython is affected because it implements a descriptor to access its underlying chandle and that shouldn't be unset. * black format * actually use handle instead of self.handle
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
init_handle_by_constructor is called (or self.handle is
otherwise set), a Python stack overflow could result. This is
because the unset handle slot causes self.handle accesses to
fallback on the getattr(self, 'handle') method, invoking
NodeGetAttr.
attributes in slots, then make del tolerant to missing
self.handle.
descriptor to access its underlying chandle and that shouldn't be unset.