Hello Sirs, I am trying to build the valgrind-3.6.0 for Android 2.2 using codesourcery toolchain <arm-2008q3>.
I would have liked to make the post shorter but as I am a newbie please forgive my ignorance and I sincerely thank you for your time. . . Here are the Details:: Valgrind have been compiled successfully but while using it I am getting segmentation fault. --> # ./valgrind valgrind: no program specified valgrind: Use --help for more information. ------------------------------------------------------------------------------------------------------------ #./valgrind /system/bin/ls ==230== --230-- WARNING: unhandled syscall: 67 --230-- You may be able to write your own handler. --230-- Read the file README_MISSING_SYSCALL_OR_IOCTL. --230-- Nevertheless we consider this a bug. Please report --230-- it at http://valgrind.org/support/bug_reports.html. ==230== Invalid write of size 4 ==230== at 0xB00061C4: ??? (in /system/bin/linker) ==230== Address 0x884a8 is not stack'd, malloc'd or (recently) free'd ==230== ==230== ==230== Process terminating with default action of signal 11 (SIGSEGV) ==230== Access not within mapped region at address 0x884A8 ==230== at 0xB00061C4: ??? (in /system/bin/linker) ==230== If you believe this happened as a result of a stack ==230== overflow in your program's main thread (unlikely but ==230== possible), you can try to increase the size of the ==230== main thread stack using the --main-stacksize= flag. ==230== The main thread stack size used in this run was 8388608. ==230== -------------------------------------------------------------------------------------------------------------------------- I tried to debug it by attaching GDB-6.8 <which in turn was built to run on the adb shell using the same toolchain>, but got problems with exec ==> =634== The main thread stack size used in this run was 8388608. ==634== ==634== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- y ==634== starting debugger with cmd: /cache/gdb -nw /proc/635/fd/1014 635 EXEC failed, errno = 2 ==634== ==634== Debugger has detached. Valgrind regains control. We continue. ==634== [1] Segmentation fault ./valgrind --db-command="/cache/gdb -nw %f %p" --db-attach=yes --tool=none /system/bin/ls ------------------------ Debugging it normally using the tool chain's gdb I am getting no stack to backtrace < Although I have compiled valgrind with -g -O0 CFLAGS > . . . I tried increasing stack size too ... but that didn't help either. =============================== = Valgrind ran on Emulator's Shell ===== =============================== # ./valgrind -v -d /system/bin/ls --453:1:debuglog DebugLog system started by Stage 1, level 1 logging requested --453:1:launcher no tool requested, defaulting to 'memcheck' --453:1:launcher selected platform 'arm-linux' --453:1:launcher launching /cache/vallibs/lib/valgrind/memcheck-arm- linux --453:1:debuglog DebugLog system started by Stage 2 (main), level 1 logging requested --453:1:main Welcome to Valgrind version 3.6.0 debug logging --453:1:main Checking current stack is plausible --453:1:main Checking initial stack was noted --453:1:main Starting the address space manager --453:1:main Address space manager is running --453:1:main Starting the dynamic memory manager --453:1:mallocfr newSuperblock at 0x615B1000 (pszB 4194288) owner VALGRIND/tool --453:1:main Dynamic memory manager is running --453:1:main Initialise m_debuginfo --453:1:main VG_(libdir) = /cache/vallibs/lib/valgrind --453:1:main Getting launcher's name ... --453:1:main ... /cache/vallibs/bin/valgrind --453:1:main Get hardware capabilities ... --453:1:machine ARMv5 VFP 1 VFP2 1 VFP3 1 NEON 0 --453:1:main ... arch = ARM, hwcaps = ARMv5-vfp --453:1:main Getting the working directory at startup --453:1:main ... /cache/vallibs/bin --453:1:main Split up command line --453:1:main (early_) Process Valgrind's command line options --453:1:main Create initial image --453:1:initimg Loading client --453:1:initimg Setup client env --453:1:initimg Setup client stack: size will be 8388608 --453:1:initimg Setup client data (brk) segment --453:1:main Setup file descriptors --453:1:main Create fake /proc/<pid>/cmdline --453:1:main Initialise the tool part 1 (pre_clo_init) --453:1:mallocfr newSuperblock at 0x619B1000 (pszB 1048560) owner VALGRIND/exectxt --453:1:main Print help and quit, if requested --453:1:main (main_) Process Valgrind's command line options, setup logging --453:1:mallocfr newSuperblock at 0x61AB1000 (pszB 1048560) owner VALGRIND/core --453:1:main Print the preamble... ==453== Memcheck, a memory error detector ==453== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==453== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info ==453== Command: /system/bin/ls ==453== --453-- Valgrind options: --453-- -v --453-- -d --453-- Contents of /proc/version: --453-- Linux version 2.6.29-00261-g0097074-dirty ([email protected]) (gcc version 4.4.0 (GCC) ) #20 Wed Mar 31 09:54:02 PDT 2010 --453-- Arch and hwcaps: ARM, ARMv5-vfp --453-- Page sizes: currently 4096, max supported 4096 --453-- Valgrind library directory: /cache/vallibs/lib/valgrind --453:1:main ...finished the preamble --453:1:main Initialise the tool part 2 (post_clo_init) --453:1:main Initialise TT/TC --453:1:main Initialise redirects --453:1:mallocfr newSuperblock at 0x61C2C000 (pszB 1048560) owner VALGRIND/dinfo --453:1:main Load initial debug info --453-- Reading syms from /system/bin/toolbox (0x8000) --453-- object doesn't have a symbol table --453-- Reading syms from /system/bin/linker (0xb0001000) --453-- object doesn't have a symbol table --453-- object doesn't have a dynamic symbol table --453:1:redir transfer ownership V -> C of 0x38042000 .. 0x38042fff --453:1:main Initialise scheduler (phase 1) --453:1:sched sched_init_phase1 --453:1:main Tell tool about initial permissions --453:1:main Initialise scheduler (phase 2) --453:1:sched sched_init_phase2: tid_main=1, cls_end=0xbdb60fff, cls_sz=8388608 --453:1:main Finalise initial image --453:1:main Initialise signal management --453:1:main Load suppressions --453-- Reading suppressions file: /cache/vallibs/lib/valgrind/ default.supp --453:1:main --453:1:main --453:1:aspacem <<< SHOW_SEGMENTS: Memory layout at client startup (29 segments, 3 segnames) --453:1:aspacem ( 0) /cache/vallibs/lib/valgrind/memcheck-arm-linux --453:1:aspacem ( 1) /system/bin/toolbox --453:1:aspacem ( 2) /system/bin/linker --453:1:aspacem 0: RSVN 0000000000-0000007fff 32768 ----- SmFixed --453:1:aspacem 1: file 0000008000-0000019fff 73728 r-x-- d=0x1f00 i=644 o=0 (1) --453:1:aspacem 2: file 000001a000-000001afff 4096 rw--- d=0x1f00 i=644 o=73728 (1) --453:1:aspacem 3: anon 000001b000-000001efff 16384 rw--- --453:1:aspacem 4: RSVN 000001f000-0003ffffff 63m ----- SmFixed --453:1:aspacem 5: anon 0004000000-0004000fff 4096 rwx-- --453:1:aspacem 6: RSVN 0004001000-00047fffff 8384512 ----- SmLower --453:1:aspacem 7: 0004800000-0037ffffff 824m --453:1:aspacem 8: FILE 0038000000-0038041fff 270336 r-x-- d=0x1f02 i=305 o=32768 (0) --453:1:aspacem 9: file 0038042000-0038042fff 4096 r-x-- d=0x1f02 i=305 o=303104 (0) --453:1:aspacem 10: FILE 0038043000-0038221fff 1961984 r-x-- d=0x1f02 i=305 o=307200 (0) --453:1:aspacem 11: 0038222000-0038228fff 28672 --453:1:aspacem 12: FILE 0038229000-003822afff 8192 rwx-- d=0x1f02 i=305 o=2265088 (0) --453:1:aspacem 13: ANON 003822b000-0038d1cfff 10m rwx-- --453:1:aspacem 14: 0038d1d000-00615affff 648m --453:1:aspacem 15: RSVN 00615b0000-00615b0fff 4096 ----- SmFixed --453:1:aspacem 16: ANON 00615b1000-0061d4bfff 7974912 rwx-- --453:1:aspacem 17: 0061d4c000-00b0000fff 1250m --453:1:aspacem 18: file 00b0001000-00b000bfff 45056 r-x-- d=0x1f00 i=567 o=4096 (2) --453:1:aspacem 19: file 00b000c000-00b000cfff 4096 rw--- d=0x1f00 i=567 o=49152 (2) --453:1:aspacem 20: anon 00b000d000-00b0015fff 36864 rw--- --453:1:aspacem 21: 00b0016000-00bd360fff 211m --453:1:aspacem 22: RSVN 00bd361000-00bdb5ffff 8384512 ----- SmUpper --453:1:aspacem 23: anon 00bdb60000-00bdb60fff 4096 rwx-- --453:1:aspacem 24: 00bdb61000-00beb4bfff 15m --453:1:aspacem 25: ANON 00beb4c000-00beb60fff 86016 rw--- --453:1:aspacem 26: RSVN 00beb61000-00fffeffff 1044m ----- SmFixed --453:1:aspacem 27: anon 00ffff0000-00ffff0fff 4096 r-x-- --453:1:aspacem 28: RSVN 00ffff1000-00ffffffff 61440 ----- SmFixed --453:1:aspacem >>> --453:1:main --453:1:main --453:1:main Running thread 1 --453:1:syswrap- entering VG_(main_thread_wrapper_NORETURN) --453:1:aspacem allocated thread stack at 0x61d4c000 size 1064960 --453:1:syswrap- run_a_thread_NORETURN(tid=1): pre-thread_wrapper --453:1:syswrap- thread_wrapper(tid=1): entry --453:1:transtab allocate sector 0 --453:1:mallocfr newSuperblock at 0x63A62000 (pszB 65520) owner VALGRIND/ttaux --453-- WARNING: unhandled syscall: 67 ==453== at 0xB000668C: ??? (in /system/bin/linker) --453-- You may be able to write your own handler. --453-- Read the file README_MISSING_SYSCALL_OR_IOCTL. --453-- Nevertheless we consider this a bug. Please report --453-- it at http://valgrind.org/support/bug_reports.html. --453:1:mallocfr newSuperblock at 0x63A72000 (pszB 65520) owner VALGRIND/errors ==453== Invalid write of size 4 ==453== at 0xB00061C4: ??? (in /system/bin/linker) ==453== Address 0x884a8 is not stack'd, malloc'd or (recently) free'd ==453== ==453== ==453== Process terminating with default action of signal 11 (SIGSEGV) ==453== Access not within mapped region at address 0x884A8 ==453== at 0xB00061C4: ??? (in /system/bin/linker) ==453== If you believe this happened as a result of a stack ==453== overflow in your program's main thread (unlikely but ==453== possible), you can try to increase the size of the ==453== main thread stack using the --main-stacksize= flag. ==453== The main thread stack size used in this run was 8388608. --453:1:syswrap- thread_wrapper(tid=1): exit --453:1:syswrap- run_a_thread_NORETURN(tid=1): post-thread_wrapper --453:1:syswrap- run_a_thread_NORETURN(tid=1): last one standing --453:1:main entering VG_(shutdown_actions_NORETURN) --453:1:aspacem <<< SHOW_SEGMENTS: Memory layout at client shutdown (33 segments, 3 segnames) --453:1:aspacem ( 0) /cache/vallibs/lib/valgrind/memcheck-arm-linux --453:1:aspacem ( 1) /system/bin/toolbox --453:1:aspacem ( 2) /system/bin/linker --453:1:aspacem 0: RSVN 0000000000-0000007fff 32768 ----- SmFixed --453:1:aspacem 1: file 0000008000-0000019fff 73728 r-x-- d=0x1f00 i=644 o=0 (1) --453:1:aspacem 2: file 000001a000-000001afff 4096 rw--- d=0x1f00 i=644 o=73728 (1) --453:1:aspacem 3: anon 000001b000-000001efff 16384 rw--- --453:1:aspacem 4: RSVN 000001f000-0003ffffff 63m ----- SmFixed --453:1:aspacem 5: anon 0004000000-0004000fff 4096 rwx-- --453:1:aspacem 6: RSVN 0004001000-00047fffff 8384512 ----- SmLower --453:1:aspacem 7: 0004800000-0037ffffff 824m --453:1:aspacem 8: FILE 0038000000-0038041fff 270336 r-x-- d=0x1f02 i=305 o=32768 (0) --453:1:aspacem 9: file 0038042000-0038042fff 4096 r-x-- d=0x1f02 i=305 o=303104 (0) --453:1:aspacem 10: FILE 0038043000-0038221fff 1961984 r-x-- d=0x1f02 i=305 o=307200 (0) --453:1:aspacem 11: 0038222000-0038228fff 28672 --453:1:aspacem 12: FILE 0038229000-003822afff 8192 rwx-- d=0x1f02 i=305 o=2265088 (0) --453:1:aspacem 13: ANON 003822b000-0038d1cfff 10m rwx-- --453:1:aspacem 14: 0038d1d000-00615affff 648m --453:1:aspacem 15: RSVN 00615b0000-00615b0fff 4096 ----- SmFixed --453:1:aspacem 16: ANON 00615b1000-0061d4bfff 7974912 rwx-- --453:1:aspacem 17: ANON 0061d4c000-0061d4dfff 8192 ----- --453:1:aspacem 18: ANON 0061d4e000-0061e4dfff 1048576 rwx-- --453:1:aspacem 19: ANON 0061e4e000-0061e4ffff 8192 ----- --453:1:aspacem 20: ANON 0061e50000-0063a81fff 28m rwx-- --453:1:aspacem 21: 0063a82000-00b0000fff 1221m --453:1:aspacem 22: file 00b0001000-00b000bfff 45056 r-xT- d=0x1f00 i=567 o=4096 (2) --453:1:aspacem 23: file 00b000c000-00b000cfff 4096 rw--- d=0x1f00 i=567 o=49152 (2) --453:1:aspacem 24: anon 00b000d000-00b0015fff 36864 rw--- --453:1:aspacem 25: 00b0016000-00bd360fff 211m --453:1:aspacem 26: RSVN 00bd361000-00bdb5ffff 8384512 ----- SmUpper --453:1:aspacem 27: anon 00bdb60000-00bdb60fff 4096 rwx-- --453:1:aspacem 28: 00bdb61000-00beb4bfff 15m --453:1:aspacem 29: ANON 00beb4c000-00beb60fff 86016 rw--- --453:1:aspacem 30: RSVN 00beb61000-00fffeffff 1044m ----- SmFixed --453:1:aspacem 31: anon 00ffff0000-00ffff0fff 4096 r-x-- --453:1:aspacem 32: RSVN 00ffff1000-00ffffffff 61440 ----- SmFixed --453:1:aspacem >>> ==453== ==453== HEAP SUMMARY: ==453== in use at exit: 0 bytes in 0 blocks ==453== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==453== ==453== All heap blocks were freed -- no leaks are possible ==453== ==453== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==453== ==453== 1 errors in context 1 of 1: ==453== Invalid write of size 4 ==453== at 0xB00061C4: ??? (in /system/bin/linker) ==453== Address 0x884a8 is not stack'd, malloc'd or (recently) free'd ==453== ==453== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) --453:1:core_os VG_(terminate_NORETURN)(tid=1) [1] Segmentation fault ./valgrind -v -d /system/bin/ls ============================================================================== =============================== = Tombstone file details===== =============================== *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'generic/sdk/generic/:2.2/FRF42/36942:eng/test- keys' pid: 331, tid: 331 >>> app_process <<< signal 11 (SIGSEGV), fault addr deadbaad r0 00000000 r1 beecb8bc r2 00000027 r3 00000000 r4 00000000 r5 deadbaad r6 beecb8bc r7 00000000 r8 00000000 r9 00000000 10 00000000 fp 00000000 ip ffffffff sp beecb8a8 lr afd11d9b pc afd11dc4 cpsr 60000030 #00 pc 00011dc4 /system/lib/libc.so #01 pc 0000135c /system/lib/liblog.so code around pc: afd11da4 1c2bd00b 2d00682d e026d1fb 2b0068db afd11db4 4e17d003 51a02001 4d164798 24002227 afd11dc4 f7fb702a 2106ee14 ef10f7fc 05592380 afd11dd4 6091aa01 1c116054 94012006 eab6f7fc afd11de4 2200a905 f7fc2002 f7fbeac2 2106ee00 code around lr: afd11d78 5963447c 2201ae05 1c304251 681d2204 afd11d88 eb26f7fd 20024920 91052200 f7fc1c31 afd11d98 481eeaec 2b005823 2d00d10d 1c2bd00b afd11da8 2d00682d e026d1fb 2b0068db 4e17d003 afd11db8 51a02001 4d164798 24002227 f7fb702a stack: beecb868 afa0109d /system/lib/liblog.so beecb86c afa030b8 /system/lib/liblog.so beecb870 ffffffff beecb874 00000003 beecb878 00000000 beecb87c afa0106d /system/lib/liblog.so beecb880 beecb8a8 [stack] beecb884 00000003 beecb888 a9c03e8f /system/lib/libskiagl.so beecb88c afa030b8 /system/lib/liblog.so beecb890 beecb8bc [stack] beecb894 afd40328 /system/lib/libc.so beecb898 40008000 beecb89c beecb8bc [stack] beecb8a0 df002777 beecb8a4 e3a070ad #00 beecb8a8 beecb8a4 [stack] beecb8ac 00000001 beecb8b0 00008de2 /system/bin/app_process beecb8b4 00000008 beecb8b8 beecb8dc [stack] beecb8bc fffffbdf beecb8c0 beecb8dc [stack] beecb8c4 00008de2 /system/bin/app_process beecb8c8 fffffca2 beecb8cc afa0135f /system/lib/liblog.so #01 beecb8d0 beecb8dc [stack] beecb8d4 afa0135f /system/lib/liblog.so beecb8d8 beecbcf4 [stack] beecb8dc 5f707061 beecb8e0 636f7270 beecb8e4 3a737365 beecb8e8 206f6e20 beecb8ec 73616c63 beecb8f0 616e2073 beecb8f4 6f20656d beecb8f8 2d2d2072 beecb8fc 6f67797a beecb900 73206574 beecb904 6c707075 beecb908 2e646569 beecb90c b0002b00 /system/bin/linker beecb910 b0002ba5 /system/bin/linker beecb914 00000005 ============================================================================== --------------------------- # ./valgrind --gen-suppressions=yes /system/bin/ls . . . --643-- WARNING: unhandled syscall: 67 --643-- You may be able to write your own handler. --643-- Read the file README_MISSING_SYSCALL_OR_IOCTL. --643-- Nevertheless we consider this a bug. Please report --643-- it at http://valgrind.org/support/bug_reports.html. ==643== Invalid write of size 4 ==643== at 0xB00061C4: ??? (in /system/bin/linker) ==643== Address 0x884a8 is not stack'd, malloc'd or (recently) free'd ==643== ==643== ==643== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ---- y { <insert_a_suppression_name_here> Memcheck:Addr4 obj:/system/bin/linker } ==643== . . . --------------------------- =strace -c output=============================================================== strace -c ./valgrind /system/bin/ls ) = 0 <0.000250> ) = 0 <0.000330> ) = 0 <0.006409> ) = 0 <0.000360> ) = 0 <0.007960> ) = 0 <0.000337> ) = 0 <0.013301> ) = 0 <0.000408> ) = 0 <0.000425> ) = 0 <0.012262> ) = 0 <0.000354> ) = 0 <0.009613> ) = 0 <0.000355> ) = 0 <0.000311> ) = 0 <0.000441> ) = 0 <0.000486> ) = 0 <0.008806> ) = 0 <0.000425> ) = 0 <0.011296> ) = 0 <0.000339> ) = 0 <0.000844> % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 64.74 0.424080 422 1006 rt_sigprocmask 8.01 0.052476 264 199 rt_sigaction 7.58 0.049643 362 137 read 5.69 0.037247 1330 28 mmap2 2.94 0.019253 4813 4 getrlimit 2.74 0.017940 561 32 write 2.18 0.014266 7133 2 munmap 1.85 0.012123 328 37 getpid 0.98 0.006411 3206 2 execve 0.88 0.005770 412 14 open 0.63 0.004106 587 7 readlink 0.35 0.002285 143 16 close 0.32 0.002094 262 8 stat64 0.21 0.001388 139 10 fcntl 0.18 0.001151 128 9 fstat64 0.12 0.000802 802 1 unlink 0.11 0.000694 116 6 lseek 0.09 0.000603 151 4 SYS_224 0.08 0.000550 138 4 brk 0.06 0.000370 185 2 mprotect 0.05 0.000346 346 1 access 0.04 0.000270 135 2 setrlimit 0.04 0.000238 238 1 kill 0.03 0.000224 224 1 pipe 0.03 0.000220 220 1 getcwd 0.03 0.000182 182 1 uname 0.02 0.000135 135 1 getppid 0.01 0.000097 97 1 msgget 0.01 0.000072 72 1 geteuid32 ------ ----------- ----------- --------- --------- ---------------- 100.00 0.655036 1538 total =strace -d output======================================================== strace -d ./valgrind /system/bin/ls ---> output file is big<2.3 KB> , if required I 'll upload that too. ===================================================================== Few Points : 1. The heap is getting corrupted leading to deadbaad in r5. 2. Is it because of memory constraints ? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

