You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/02/19 23:47:06 UTC

[GitHub] [tvm] areusch opened a new pull request #7481: Fix stack overflow when partially-__init__ Node raises exception.

areusch opened a new pull request #7481:
URL: https://github.com/apache/tvm/pull/7481


    * 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.
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on a change in pull request #7481: Fix stack overflow when partially-__init__ Node raises exception.

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on a change in pull request #7481:
URL: https://github.com/apache/tvm/pull/7481#discussion_r580628667



##########
File path: python/tvm/_ffi/_ctypes/object.py
##########
@@ -106,6 +106,11 @@ class ObjectBase(object):
 
     def __del__(self):
         if _LIB is not None:
+            try:
+                handle = self.handle

Review comment:
       gotcha. Thanks!




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #7481: Fix stack overflow when partially-__init__ Node raises exception.

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7481:
URL: https://github.com/apache/tvm/pull/7481#discussion_r580612333



##########
File path: python/tvm/_ffi/_ctypes/object.py
##########
@@ -106,6 +106,11 @@ class ObjectBase(object):
 
     def __del__(self):
         if _LIB is not None:
+            try:
+                handle = self.handle

Review comment:
       I thought about that but I think hasattr() is slow and this way we only enter the slow case when bad things happen




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on a change in pull request #7481: Fix stack overflow when partially-__init__ Node raises exception.

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on a change in pull request #7481:
URL: https://github.com/apache/tvm/pull/7481#discussion_r579712698



##########
File path: python/tvm/_ffi/_ctypes/object.py
##########
@@ -106,6 +106,11 @@ class ObjectBase(object):
 
     def __del__(self):
         if _LIB is not None:
+            try:
+                handle = self.handle

Review comment:
       can we use hasattr(self, “handle”)?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on a change in pull request #7481: Fix stack overflow when partially-__init__ Node raises exception.

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on a change in pull request #7481:
URL: https://github.com/apache/tvm/pull/7481#discussion_r579712698



##########
File path: python/tvm/_ffi/_ctypes/object.py
##########
@@ -106,6 +106,11 @@ class ObjectBase(object):
 
     def __del__(self):
         if _LIB is not None:
+            try:
+                handle = self.handle

Review comment:
       We can use hasattr(self, “handle”)




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch commented on pull request #7481: Fix stack overflow when partially-__init__ Node raises exception.

Posted by GitBox <gi...@apache.org>.
areusch commented on pull request #7481:
URL: https://github.com/apache/tvm/pull/7481#issuecomment-782460728


   @tqchen @merrymercy @rkimball @jroesch @tkonolige @junrushao1994 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] tqchen merged pull request #7481: Fix stack overflow when partially-__init__ Node raises exception.

Posted by GitBox <gi...@apache.org>.
tqchen merged pull request #7481:
URL: https://github.com/apache/tvm/pull/7481


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org