Created attachment 110834 [details] test.c Platform is mips linux # cat /proc/version Linux version 3.4.11-rt19 (gcc version 4.6.2 (Buildroot 2011.11) ) #2 SMP PREEMPT Compile attached test.c with below command: mips-linux-gcc -g -O0 -fno-omit-frame-pointer -fno-stack-check test.c There's no file number shown in valgrind report: # valgrind --trace-children=yes --leak-check=yes --num-callers=20 /tmp/a.out ==2957== Memcheck, a memory error detector ==2957== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==2957== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==2957== Command: /tmp/a.out ==2957== ==2957== Invalid write of size 4 ==2957== at 0x4000B90: ??? (in /lib/ld-uClibc.so.0) ==2957== by 0x4000B3C: ??? (in /lib/ld-uClibc.so.0) ==2957== Address 0x7e8bdcbc is on thread 1's stack ==2957== 4 bytes below stack pointer ==2957== ==2957== Conditional jump or move depends on uninitialised value(s) ==2957== at 0x48B4A44: ??? (in /lib/libc.so.0) ==2957== by 0x48ADBE4: ??? (in /lib/libc.so.0) ==2957== buf=test buf in func1:x[10]=10 /tmp/a.out: can't resolve symbol '__libc_freeres' ==2957== ==2957== HEAP SUMMARY: ==2957== in use at exit: 0 bytes in 0 blocks ==2957== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==2957== ==2957== All heap blocks were freed -- no leaks are possible ==2957== ==2957== For counts of detected and suppressed errors, rerun with: -v ==2957== Use --track-origins=yes to see where uninitialised values come from ==2957== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Compiling your program with -fno-omit-frame-pointer doesn't help if the problem occurs in libc and libc has been compiled without any way to unwind the stack. Almost certainly your libc does not have DWARF frame unwind information available and has been compiled without frame pointers (completely normal these days). If your distro has debug packages then installing the debug package for libc may well help.
Thanks for the response, my libc.so.0 is stripped, I replaced it with unstripped one and now valgrind works fine.