Bug 390765

Summary: Stack traces given by Memcheck aren't helpful
Product: [Developer tools] valgrind Reporter: sarah_w
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: sarah_w, tom
Priority: NOR    
Version: 3.13.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: test.c

Description sarah_w 2018-02-20 08:21:30 UTC
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)
Comment 1 Tom Hughes 2018-02-20 09:19:07 UTC
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.
Comment 2 sarah_w 2018-02-24 02:52:19 UTC
Thanks for the response, my libc.so.0 is stripped, I replaced it with unstripped one and now valgrind works fine.