RE: [arm-gnu] Core File seems to be corrupted
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [arm-gnu] Core File seems to be corrupted



Hi Daniel,

   Could you please help me with my issue ?

   I have set solib-absolute-prefix variable and still I'm seeing the
"??" only.
   I tried absolute path and also the relative path, still no luck for
me.

(gdb) set solib-absolute-prefix
./lib:./:../ipaccess/lib:../:../lib:./ipaccess/lib:/u01/balkani/TR069/fr
amework/build/TR069:/u01/balkani/TR069/framework/build/TR069/lib:/u01/ba
lkani/TR069/framework/build/TR069/ipaccess/lib
 (gdb) show solib-absolute-prefix
Prefix for loading absolute shared library symbol files is
"./lib:./:../ipaccess/lib:../:../lib:./ipaccess/lib:/u01/balkani/TR069/f
ramework/build/TR069:/u01/balkani/TR069/framework/build/TR069/lib:/u01/b
alkani/TR069/framework/build/TR069/ipaccess/lib".

   Also, I noticed an error when I print the backtrace " Previous frame
identical to this frame (corrupt stack?)"

   Any thoughts on this issue ?

(gdb) where
#0  0x402b39d8 in ?? ()
#1  0x40299004 in ?? ()
#2  0x40299004 in ?? ()
Previous frame identical to this frame (corrupt stack?)

   Since backtrace is not yeiding the function names, I thought of
adding signal handler
   to print  function pointers and function names during crash. Even
that, I'm not able to make it print.

   I got the following traces and it does not have contain the function
names.
   Could you please let me know incase if I'm doing something wrong here
?

Dec 22 12:39:31 ip202ff user.info DslmSsp: in catch_segfault signal
recieved 15                 
Dec 22 12:39:31 ip202ff user.info DslmSsp: lp[0]: 0xbed19540 ra: 0x2ccb8
next: 0xbed19984       
Dec 22 12:39:31 ip202ff user.info DslmSsp: lp[1]: 0xbed19978 ra: 0x3
next: (nil)                
Dec 22 12:39:31 ip202ff user.info DslmSsp: __arm_backtrace size 2

Dec 22 12:39:31 ip202ff user.info DslmSsp: backtrace_symbols invoked

Dec 22 12:39:31 ip202ff user.info DslmSsp: backtrace_symbols completed

Dec 22 12:39:31 ip202ff user.info DslmSsp: Obtained 2 stack frames.

Dec 22 12:39:31 ip202ff user.info DslmSsp: ./DslmSsp [0x2ccb8]

Dec 22 12:39:31 ip202ff user.info DslmSsp: [0x3]


Regards, Balaji

-----Original Message-----
From: Daniel Jacobowitz [mailto:dan@xxxxxxxxxxxxxxxx] 
Sent: Monday, December 21, 2009 8:05 PM
To: Balaji Kani -X (balkani - WIPRO at Cisco)
Cc: arm-gnu@xxxxxxxxxxxxxxxx
Subject: Re: [arm-gnu] Core File seems to be corrupted

On Mon, Dec 21, 2009 at 07:55:31PM +0530, Balaji Kani -X (balkani -
WIPRO at Cisco) wrote:
>    Is this the known issue in Sourcery G++ 2006q3-26 version or 
>    Something to do with my setting ? If so, could you please suggest
>    What would have went wrong ?

You need to tell GDB where your libraries are before it can trace
through them.

-- 
Daniel Jacobowitz
CodeSourcery
arm-none-linux-gnueabi-gdb
GNU gdb (CodeSourcery ARM Sourcery G++ 2006q3-26) 6.5.50.20060822-cvs
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi".
For bug reporting instructions, please see:
<URL:mailto:arm-gnu@xxxxxxxxxxxxxxxx>.


(gdb) set solib-absolute-prefix ./lib:./:../ipaccess/lib:../:../lib:./ipaccess/lib
(gdb) show solib-absolute-prefix
Prefix for loading absolute shared library symbol files is "./lib:./:../ipaccess/lib:../:../lib:./ipaccess/lib".


(gdb) file /u01/balkani/TR069/framework/build/TR069/DslmSsp
Reading symbols from /u01/balkani/TR069/framework/build/TR069/DslmSsp...done.
(gdb) core-file /u01/balkani/CRASH/core_11_DslmSsp.16355
Cannot access memory at address 0x400256b0
(gdb) where
#0  0x402b39d8 in ?? ()
#1  0x40299004 in ?? ()
#2  0x40299004 in ?? ()
Previous frame identical to this frame (corrupt stack?)
(gdb) 


+++++

(gdb) core /u01/balkani/CRASH/core_11_DslmSspss.16355
Cannot access memory at address 0x400256b0
(gdb) where
#0  0x402b39d8 in ?? ()
#1  0x40299004 in ?? ()
#2  0x40299004 in ?? ()


+++++

(gdb) set solib-absolute-prefix ./lib:./:../ipaccess/lib:../:../lib:./ipaccess/lib:/u01/balkani/TR069/framework/build/TR069:/u01/balkani/TR069/framework/build/TR069/lib:/u01/balkani/TR069/framework/build/TR069/ipaccess/lib

(gdb) file /u01/balkani/TR069/framework/build/TR069/DslmSsp
Reading symbols from /u01/balkani/TR069/framework/build/TR069/DslmSsp...done.

(gdb) show solib-absolute-prefix
Prefix for loading absolute shared library symbol files is "./lib:./:../ipaccess/lib:../:../lib:./ipaccess/lib:/u01/balkani/TR069/framework/build/TR069:/u01/balkani/TR069/framework/build/TR069/lib:/u01/balkani/TR069/framework/build/TR069/ipaccess/lib".

(gdb) core /u01/balkani/CRASH/core_11_DslmSspss.16355
Cannot access memory at address 0x400256b0
(gdb) where
#0  0x402b39d8 in ?? ()
#1  0x40299004 in ?? ()
#2  0x40299004 in ?? ()
Previous frame identical to this frame (corrupt stack?)
(gdb) 
[balkani@ssevm32 ssp]$ svn diff
Index: ssp_main.c
===================================================================
--- ssp_main.c  (revision 17049)
+++ ssp_main.c  (working copy)
@@ -46,7 +46,20 @@
+#include <stdio.h>
+#include <execinfo.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <pthread.h>
+#include <signal.h>
 
+struct layout {
+   struct layout *__unbounded next;
+   void *__unbounded sp;
+   void *__unbounded return_address;
+};
+
 /*******************************************************************
                         EXTERNAL ROUTINES
 *******************************************************************/
@@ -979,11 +992,89 @@
        }
 }
 
+int
+__arm_backtrace(int **arr, int maxsiz)
+{
+   int cnt = 0;
+   void *fp = __builtin_frame_address (0);
+   struct layout *lp = (struct layout *)(fp - 12);
+      while (cnt < maxsiz) {
+       syslog(LOG_INFO, "lp[%d]: %p ra: %p next: %p\n", cnt, (void *)lp, (void *)lp->return_address, (void *)lp->next);
+       arr[cnt++] = (void *)lp->return_address;
+       if (!lp->next) {
+           break;
+       }
+       lp = lp->next - 1;
+   }
+   return cnt;
+}
 
+static void
+catch_segfault (int signal, struct sigcontext ctx)
+{  
+   int *arr[32];
+   int size, i;
+   struct sigaction sa;
+   char **strings;
+
+   syslog(LOG_INFO, "in %s signal recieved %d\n", __FUNCTION__, signal);
+
+   size = __arm_backtrace(arr, 32);
+   syslog(LOG_INFO, "__arm_backtrace size %d \n", size);
+   syslog(LOG_INFO, "backtrace_symbols invoked");
+   strings = backtrace_symbols ((void **)arr, size);
+   syslog(LOG_INFO, "backtrace_symbols completed");
+
+   syslog(LOG_INFO, "Obtained %zd stack frames.\n", size);
+   for (i = 0; i < size; i++)
+       syslog(LOG_INFO, "%s\n", strings[i]);
+   free (strings);
+
+   /* Pass on the signal (so that a core file is produced).  */
+   sa.sa_handler = SIG_DFL;
+   sigemptyset (&sa.sa_mask);
+   sa.sa_flags = 0;
+   sigaction (signal, &sa, NULL);
+   raise (signal);
+   return;
+}
+
+void
+install_fh(void)
+{
+   struct sigaction new_action;
+   char *path = NULL;
+   char *where;
+   int signal_no;
+   
+   memset (&new_action, '\0', sizeof(new_action));
+   new_action.sa_handler = catch_segfault;
+   sigemptyset (&new_action.sa_mask);
+   new_action.sa_flags = 0;
+   
+   for (signal_no = 1; signal_no <= SIGUNUSED; signal_no++) {
+        if (signal_no == SIGTERM || signal_no == SIGSTKFLT ||
+            signal_no == SIGSEGV || signal_no == SIGFPE ||
+            signal_no == SIGKILL || signal_no == SIGBUS ||
+            signal_no == SIGILL) {
+        if (sigaction(signal_no, &new_action, NULL) < 0) {
+            syslog(LOG_INFO, "install_fh sigaction failed - %d", signal_no);
+        }
+        }
+   }
+}
+
 int main(int argc, char* argv[])
 {
     BOOLEAN                         bDaemonize  = TRUE;
+
+            syslog(LOG_INFO, "install_fh is invoked");
+            printf("install_fh is invoked");
+            install_fh();