From owner-freebsd-hackers@freebsd.org Mon Jun 17 02:48:13 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6EFE715D0D4B for ; Mon, 17 Jun 2019 02:48:13 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from mail.farhan.codes (mail.farhan.codes [155.138.165.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E71EE72964 for ; Mon, 17 Jun 2019 02:48:11 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from mail.farhan.codes (rainloop [172.16.0.4]) by mail.farhan.codes (Postfix) with ESMTPSA id B64DCF737; Sun, 16 Jun 2019 22:48:03 -0400 (EDT) MIME-Version: 1.0 Date: Mon, 17 Jun 2019 02:48:03 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: RainLoop/1.12.1 From: "Farhan Khan" Message-ID: Subject: Re: Valgrind memcheck showing question marks To: "David CARLIER" Cc: freebsd-hackers@freebsd.org In-Reply-To: References: <20190605095411.GA8120@pc.farhan.codes> X-Rspamd-Queue-Id: E71EE72964 X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.64 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[farhan.codes:s=mail]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(0.38)[0.377,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[farhan.codes:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[farhan.codes,reject]; MX_GOOD(-0.01)[mail.farhan.codes]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; IP_SCORE(-0.01)[asn: 20473(-0.01), country: US(-0.06)]; ASN(0.00)[asn:20473, ipnet:155.138.160.0/20, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jun 2019 02:48:13 -0000 June 5, 2019 5:58 AM, "David CARLIER" wrote:=0A=0A> = Hi if that helps you can try -O0 in addition of -g.=0A> =0A> Regards.=0A>= =0A> On Wed, 5 Jun 2019 at 09:56, Farhan Khan via freebsd-hackers=0A> wrote:=0A> =0A>> Hi all,=0A>> =0A>> I am havi= ng a Segmentation fault error and trying to use valgrind to help me find = where the=0A>> overflow occurs. I run valgrind on the prog.full version o= f the executable.=0A>> =0A>> I am running it as follows:=0A>> =0A>> $ val= grind --tool=3Dmemcheck ogit.full [arguments omitted]=0A>> =0A>> =3D=3D14= 457=3D=3D Memcheck, a memory error detector=0A>> =3D=3D14457=3D=3D Copyri= ght (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.=0A>> =3D=3D1445= 7=3D=3D Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright inf= o=0A>> =3D=3D14457=3D=3D Command: ogit.full clone http://git.farhan.codes= /farhan/opengit=0A>> =3D=3D14457=3D=3D=0A>> =3D=3D14457=3D=3D Conditional= jump or move depends on uninitialised value(s)=0A>> =3D=3D14457=3D=3D at= 0x49D1867: ??? (in /lib/libc.so.7)=0A>> =3D=3D14457=3D=3D by 0x7FF00051F= : ???=0A>> =3D=3D14457=3D=3D by 0x20DE7D: ??? (in /usr/home/farhan/opengi= t/ogit.full)=0A>> =3D=3D14457=3D=3D by 0x20ECE1: ??? (in /usr/home/farhan= /opengit/ogit.full)=0A>> =3D=3D14457=3D=3D by 0x2054B5: ??? (in /usr/home= /farhan/opengit/ogit.full)=0A>> =3D=3D14457=3D=3D by 0x20511A: ??? (in /u= sr/home/farhan/opengit/ogit.full)=0A>> =3D=3D14457=3D=3D by 0x4826FFF: ??= ?=0A>> =3D=3D14457=3D=3D=0A>> [snippet]=0A>> =0A>> Please note that the s= tack trace does not show the function names, which I need. How do I enabl= e=0A>> those symbols?=0A>> =0A>> The Makefile is as follows:=0A>> -------= -----------=0A>> MAN=3D=0A>> =0A>> CFLAGS=3D -Wall -lmd -lz -lfetch=0A>> = =0A>> PROG=3D ogit=0A>> =0A>> SRCS=3D ogit.c lib/ini.c lib/index.c lib/co= mmon.c lib/pack.c remote.c init.c \=0A>> lib/zlib-handler.c lib/buffering= .c lib/loose.c \=0A>> hash-object.c update-index.c cat-file.c log.c clone= .c index-pack.c=0A>> =0A>> CLEANFILES+=3D ${PROG}.core=0A>> =0A>> .includ= e =0A>> ------------------=0A>> =0A>> An example compilation= line and the ending is as follows. The first line is for "index-pack.c",= but=0A>> there are others as the SRCS line shows.=0A>> -----------------= -=0A>> cc -Wall -lmd -lz -lfetch -g -MD -MF.depend.index-pack.o -MTindex-= pack.o -std=3Dgnu99=0A>> -fstack-protector-strong -Qunused-arguments -c i= ndex-pack.c -o index-pack.o=0A>> cc -Wall -lmd -lz -lfetch -g -std=3Dgnu9= 9 -fstack-protector-strong -Qunused-arguments -o ogit.full=0A>> ogit.o li= b/ini.o lib/index.o lib/common.o lib/pack.o remote.o init.o lib/zlib-hand= ler.o=0A>> lib/buffering.o lib/loose.o hash-object.o update-index.o cat-f= ile.o log.o clone.o index-pack.o=0A>> objcopy --only-keep-debug ogit.full= ogit.debug=0A>> objcopy --strip-debug --add-gnu-debuglink=3Dogit.debug o= git.full ogit=0A>> ------------------=0A>> =0A>> Am I missing a necessary= compilation flag to have those symbols appear? I have "-g" turned on=0A>= > during compilation.=0A>> Thanks,=0A>> =0A>> ---=0A>> Farhan Khan=0A>> P= GP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE=0A=0AI = have -O0 and -g in my Makefile, but that does not appear to change the is= sue. It appears that debugging symbols are stripped out towards the end o= f the compilation and creates 'prog.full' and 'prog.debug', as follows:= =0A=0Acc -O2 -pipe -Wunreachable-code -Werror -O0 -g -Wall -I/usr/home/fa= rhan/opengit/src/.. -g -std=3Dgnu99 -fstack-protector-strong -Qunused-arg= uments -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 =0Aobjcopy --only-keep-debug o= git.full ogit.debug=0Aobjcopy --strip-debug --add-gnu-debuglink=3Dogit.de= bug ogit.full ogit=0A=0ANotice how the debugging symbols are written to = "ogit.debug". Is there a way to use that debug file with valgrind?=0AI sh= ould add, I also tried to manually run the compilation line without the t= wo objcopy(1) lines, but valgrind also produced the same result.=0A=0AAss= istance is appreciated :)=0A=0AThanks,=0A---=0AFarhan Khan=0APGP Fingerpr= int: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE