You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/11/04 18:15:16 UTC

[GitHub] [incubator-mxnet] szha commented on a change in pull request #19475: Avoid segfault when calling __repr__ on ndarray or symbol with freed handle

szha commented on a change in pull request #19475:
URL: https://github.com/apache/incubator-mxnet/pull/19475#discussion_r517539714



##########
File path: python/mxnet/symbol/symbol.py
##########
@@ -73,12 +73,15 @@ def as_nd_ndarray(self):
 
     def __repr__(self):
         """Gets a string representation of the symbol."""
-        name = self.name
-        if name is None:
-            name = ', '.join([i.name for i in self])
-            return '<%s group [%s]>' % (self.__class__.__name__, name)
+        if self._alive:
+            name = self.name
+            if name is None:
+                name = ', '.join([i.name for i in self])
+                return '<%s group [%s]>' % (self.__class__.__name__, name)
+            else:
+                return '<%s %s>' % (self.__class__.__name__, name)
         else:
-            return '<%s %s>' % (self.__class__.__name__, name)
+            return 'FREED Symbol'

Review comment:
       ```suggestion
               return '<FREED {}>'.format(self.__class__.__name__)
   ```




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