Valgrind memcheck showing question marks
Farhan Khan
farhan at farhan.codes
Mon Jun 17 02:48:13 UTC 2019
June 5, 2019 5:58 AM, "David CARLIER" <devnexen at gmail.com> wrote:
> Hi if that helps you can try -O0 in addition of -g.
>
> Regards.
>
> On Wed, 5 Jun 2019 at 09:56, Farhan Khan via freebsd-hackers
> <freebsd-hackers at freebsd.org> wrote:
>
>> Hi all,
>>
>> I am having a Segmentation fault error and trying to use valgrind to help me find where the
>> overflow occurs. I run valgrind on the prog.full version of the executable.
>>
>> I am running it as follows:
>>
>> $ valgrind --tool=memcheck ogit.full [arguments omitted]
>>
>> ==14457== Memcheck, a memory error detector
>> ==14457== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
>> ==14457== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
>> ==14457== Command: ogit.full clone http://git.farhan.codes/farhan/opengit
>> ==14457==
>> ==14457== Conditional jump or move depends on uninitialised value(s)
>> ==14457== at 0x49D1867: ??? (in /lib/libc.so.7)
>> ==14457== by 0x7FF00051F: ???
>> ==14457== by 0x20DE7D: ??? (in /usr/home/farhan/opengit/ogit.full)
>> ==14457== by 0x20ECE1: ??? (in /usr/home/farhan/opengit/ogit.full)
>> ==14457== by 0x2054B5: ??? (in /usr/home/farhan/opengit/ogit.full)
>> ==14457== by 0x20511A: ??? (in /usr/home/farhan/opengit/ogit.full)
>> ==14457== by 0x4826FFF: ???
>> ==14457==
>> [snippet]
>>
>> Please note that the stack trace does not show the function names, which I need. How do I enable
>> those symbols?
>>
>> The Makefile is as follows:
>> ------------------
>> MAN=
>>
>> CFLAGS= -Wall -lmd -lz -lfetch
>>
>> PROG= ogit
>>
>> SRCS= ogit.c lib/ini.c lib/index.c lib/common.c lib/pack.c remote.c init.c \
>> lib/zlib-handler.c lib/buffering.c lib/loose.c \
>> hash-object.c update-index.c cat-file.c log.c clone.c index-pack.c
>>
>> CLEANFILES+= ${PROG}.core
>>
>> .include <bsd.prog.mk>
>> ------------------
>>
>> An example compilation line and the ending is as follows. The first line is for "index-pack.c", but
>> there are others as the SRCS line shows.
>> ------------------
>> cc -Wall -lmd -lz -lfetch -g -MD -MF.depend.index-pack.o -MTindex-pack.o -std=gnu99
>> -fstack-protector-strong -Qunused-arguments -c index-pack.c -o index-pack.o
>> cc -Wall -lmd -lz -lfetch -g -std=gnu99 -fstack-protector-strong -Qunused-arguments -o ogit.full
>> ogit.o lib/ini.o lib/index.o lib/common.o lib/pack.o remote.o init.o lib/zlib-handler.o
>> lib/buffering.o lib/loose.o hash-object.o update-index.o cat-file.o log.o clone.o index-pack.o
>> objcopy --only-keep-debug ogit.full ogit.debug
>> objcopy --strip-debug --add-gnu-debuglink=ogit.debug ogit.full ogit
>> ------------------
>>
>> Am I missing a necessary compilation flag to have those symbols appear? I have "-g" turned on
>> during compilation.
>> Thanks,
>>
>> ---
>> Farhan Khan
>> PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE
I have -O0 and -g in my Makefile, but that does not appear to change the issue. It appears that debugging symbols are stripped out towards the end of the compilation and creates 'prog.full' and 'prog.debug', as follows:
cc -O2 -pipe -Wunreachable-code -Werror -O0 -g -Wall -I/usr/home/farhan/opengit/src/.. -g -std=gnu99 -fstack-protector-strong -Qunused-arguments -lmd -lz -lfetch /usr/home/farhan/opengit/src/../lib/libogit.a -o ogit.full ogit.o remote.o init.o hash-object.o update-index.o cat-file.o log.o clone.o clone_http.o index-pack.o
objcopy --only-keep-debug ogit.full ogit.debug
objcopy --strip-debug --add-gnu-debuglink=ogit.debug ogit.full ogit
Notice how the debugging symbols are written to "ogit.debug". Is there a way to use that debug file with valgrind?
I should add, I also tried to manually run the compilation line without the two objcopy(1) lines, but valgrind also produced the same result.
Assistance is appreciated :)
Thanks,
---
Farhan Khan
PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE
More information about the freebsd-hackers
mailing list