trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject git commit: [TS-1109] stack dump may crash too Author: zym Review/Test: zym, zwoop, igalic Backport: briang
Date Mon, 07 May 2012 18:23:35 GMT
Updated Branches:
  refs/heads/3.0.x 8b4180995 -> e626f8c4f


[TS-1109] stack dump may crash too
Author: zym
Review/Test: zym,zwoop,igalic
Backport: briang


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e626f8c4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e626f8c4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e626f8c4

Branch: refs/heads/3.0.x
Commit: e626f8c4fcdd829fd3e5b4e75384fe4025622236
Parents: 8b41809
Author: Brian Geffon <briang@apache.org>
Authored: Mon May 7 11:21:41 2012 -0700
Committer: Brian Geffon <briang@apache.org>
Committed: Mon May 7 11:21:41 2012 -0700

----------------------------------------------------------------------
 CHANGES                   |    2 +
 STATUS                    |    5 ---
 lib/ts/ink_stack_trace.cc |   68 ++-------------------------------------
 3 files changed, 6 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e626f8c4/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 0fc3e31..abe99a5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 3.0.5
+  *) [TS-1109] stack dump may crash too
+
   *) [TS-1098] make rc script support Amazon EC2 linux AMI
 
   *) [TS-1185] fix build issues with clang

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e626f8c4/STATUS
----------------------------------------------------------------------
diff --git a/STATUS b/STATUS
index 4b5021d..316e1c4 100644
--- a/STATUS
+++ b/STATUS
@@ -56,11 +56,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
    Jira: https://issues.apache.org/jira/browse/TS-1111
    +1: zym, zwoop, igalic
 
-  *) stack dump may crash too
-   master SHA: ad6c4ab97ff150727660f66aa64b0fb57fd3d3f7
-   Jira: https://issues.apache.org/jira/browse/TS-1109
-   +1: zym, zwoop, igalic
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e626f8c4/lib/ts/ink_stack_trace.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_stack_trace.cc b/lib/ts/ink_stack_trace.cc
index 116b6ba..d1ab657 100644
--- a/lib/ts/ink_stack_trace.cc
+++ b/lib/ts/ink_stack_trace.cc
@@ -34,67 +34,6 @@
 #include <execinfo.h>           /* for backtrace_symbols, etc. */
 #include <signal.h>
 
-#if defined(linux)
-/* TODO: port this more correctly to non-Linux platforms. */
-#define HAVE_SIGCONTEXT
-#endif
-
-struct sigframe
-{
-  char *pretcode;
-  int sig;
-#ifdef HAVE_SIGCONTEXT
-  struct sigcontext sc;
-#endif
-};
-
-static void
-ink_restore_signal_handler_frame(void **stack, int len, int signalhandler_frame)
-{
-#ifdef HAVE_SIGCONTEXT
-    void **fp;
-  int i;
-  struct sigframe *sf;
-  struct sigcontext *scxt;
-
-#if defined(__i386__)
-  asm volatile ("movl %%ebp,%0":"=r" (fp));
-#elif defined(__x86_64__)
-  asm volatile ("mov %%rbp,%0":"=r" (fp));
-#elif defined(__arm__)
-  asm volatile ("mov %%r9,%0":"=r" (fp));
-#endif
-  for (i = 0; i < signalhandler_frame; i++)
-    fp = (void **) (*fp);
-  sf = (struct sigframe *) (fp + 1);
-  scxt = &(sf->sc);
-#if defined(__i386__)
-  stack[signalhandler_frame + 1] = (void *) scxt->eip;
-#elif defined(__x86_64__)
-  stack[signalhandler_frame + 1] = (void *) scxt->rip;
-#elif defined(__arm__)
-  stack[signalhandler_frame + 1] = (void *) scxt->arm_ip;
-#endif
-  for (i = signalhandler_frame + 2; i < len - 1; i++)
-    stack[i] = stack[i + 1];
-#endif
-}
-
-int
-ink_stack_trace_get(void **stack, int len, int signalhandler_frame)
-{
-  int btl, i;
-  if ((btl = backtrace(stack, len)) > 0) {
-    if (signalhandler_frame)
-      ink_restore_signal_handler_frame(stack, btl, signalhandler_frame + 1);
-    // remove the frame corresponding to ink_backtrace &
-    // ink_stack_trace_get
-    for (i = 0; i < btl - 2; i++)
-      stack[i] = stack[i + 2];
-  }
-  return btl - 2;
-}
-
 void
 ink_stack_trace_dump(int sighandler_frame)
 {
@@ -111,10 +50,11 @@ ink_stack_trace_dump(int sighandler_frame)
 
   void *stack[INK_STACK_TRACE_MAX_LEVELS + 1];
   memset(stack, 0, sizeof(stack));
-  btl = ink_stack_trace_get(stack, INK_STACK_TRACE_MAX_LEVELS, sighandler_frame);
 
-  // dump the backtrace to stderr
-  backtrace_symbols_fd(stack, btl, 2);
+  if ((btl = backtrace(stack, INK_STACK_TRACE_MAX_LEVELS)) > 2) {
+    // dump the backtrace to stderr
+    backtrace_symbols_fd(stack + 2, btl - 2, 2);
+  }
 }
 
 #else  /* !TS_HAS_BACKTRACE */


Mime
View raw message