piiswrong commented on a change in pull request #8851: Use backtrace from 
dmlc-core (dmlc::stack_trace())
URL: https://github.com/apache/incubator-mxnet/pull/8851#discussion_r156195856
 
 

 ##########
 File path: src/initialize.cc
 ##########
 @@ -25,37 +25,23 @@
 #include <signal.h>
 #include <dmlc/logging.h>
 #include <mxnet/engine.h>
-
 #include "engine/profiler.h"
 
 namespace mxnet {
-
-void segfault_logger(int sig) {
-  const int MAX_STACK_SIZE = 10;
-  void *stack[MAX_STACK_SIZE];
-
+#if MXNET_USE_SIGNAL_HANDLER && DMLC_LOG_STACK_TRACE
+static void SegfaultLogger(int sig) {
   fprintf(stderr, "\nSegmentation fault: %d\n\n", sig);
-
-#if DMLC_LOG_STACK_TRACE
-  int nframes = backtrace(stack, MAX_STACK_SIZE);
-  fprintf(stderr, "Stack trace returned %d entries:\n", nframes);
-  char **msgs = backtrace_symbols(stack, nframes);
-  if (msgs != nullptr) {
-    for (int i = 0; i < nframes; ++i) {
-      fprintf(stderr, "[bt] (%d) %s\n", i, msgs[i]);
-    }
-  }
-#endif  // DMLC_LOG_STACK_TRACE
-
+  fprintf(stderr, "%s", dmlc::StackTrace().c_str());
 
 Review comment:
   Is `dmlc::StackTrace().c_str()` safe? wouldn't the pointer be invalid 
because the returned string will be released?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to