From nobody Tue Jan 18 13:03:46 2022
X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
	by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 86BD3196DAAC
	for <freebsd-questions@mlmmj.nyi.freebsd.org>; Tue, 18 Jan 2022 13:04:03 +0000 (UTC)
	(envelope-from sagarawmw@yahoo.com)
Received: from sonic309-20.consmr.mail.gq1.yahoo.com (sonic309-20.consmr.mail.gq1.yahoo.com [98.137.65.146])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(Client did not present a certificate)
	by mx1.freebsd.org (Postfix) with ESMTPS id 4JdTVp0vfyz3NVk
	for <freebsd-questions@FreeBSD.org>; Tue, 18 Jan 2022 13:04:02 +0000 (UTC)
	(envelope-from sagarawmw@yahoo.com)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1642511035; bh=atsMAu1CfX1/V5OyOJGXFbt/vELjWfeB+2HXxUB8X2U=; h=Date:From:To:Subject:References:From:Subject:Reply-To; b=hqc83GBn0Wds/bdLKzKcq99EnYCT4pJMH3rgHfIe5oBmspgnl3YHPGrjeddO8myLHMCrPdMxbJGp4klF4Sd1JodeDs8y6KpOK/ekgvwTVWctkHbYPLY6kcSm7AnLfjP6CDjX7LfJSJ26P5/QCf1pNYx9nNAcSjBkL2+HhzhUFXMSNJJK4Ryg2C1pmsd7ijG89p6U4bQ/u3l1NYPUU84UDK79uzh84CI3MYWFJcJsYBJqXh/Czb31mOPCYTaFvXx9asnHvvM3IJexOfhrx9hoASgpogczmkuiNlzevZ9+JcNDsKDLtq6H5iKC3Vkg51TYYV6msqO+zCoeZnjQ2WRZlw==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1642511035; bh=tkt0kCf6z23bsyDMwRKQXWBz1wq8PMmN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8h0C21P29ifxZkGynSTWirWVdd5FhAmInCQfXFDCetHxoT.6N9rBN8Atm1
 oq.z5mKEMdt3f7oB33T7b3hGke4b.1VbEq5bDI._Hda5RuFy37WNcfT_kbyVuQe3WC4S3j5twh0u
 m_s.fYcjWWGBEVQg.jFRf7teFtotgKzgw4gybk60S5tlp1zWw5p06RabipAM2rf8vCYcp_4xNGpB
 ZagzydPtiftIVrKmYWncSzbuwmtLmC9HcqeaGh.TsQ2fle.e6jx.3TjmfIU.Vk2lvNVwbUz3c_vj
 egjHLHrTPFsJAhvcVyinpTr08niEePw8DxLkHtDj9Y0fZsD5DD3V_7sEpujs6XQerlxYDjtcR70v
 pkbwlBHYA9ukCtf_gLCT_ZeiPEqzhVvWf9K69rOkpmu9uQWsoSHClhpHzrIdLg1NkMy3LwMBIAnY
 qLAULm_L4kZCDF9kmfrn_sgFRrVUHoBEbxVi1LA8xcQNSopBQTTdJSGK1mzmAiSD.dFm6xn_VIQd
 VmTv9OsEkesyGAFCfSpdr7I8YgTV8IviR59kpfqEBXwEKdw--
X-Sonic-MF: <sagarawmw@yahoo.com>
Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.gq1.yahoo.com with HTTP; Tue, 18 Jan 2022 13:03:55 +0000
Date: Tue, 18 Jan 2022 13:03:46 +0000 (UTC)
From: Sagara Wijetunga <sagarawmw@yahoo.com>
To: "freebsd-questions@FreeBSD.org" <freebsd-questions@FreeBSD.org>
Message-ID: <366091554.1057409.1642511026145@mail.yahoo.com>
Subject: How to disable clang AddressSanitizer instrumentation for a
 function on FreeBSD?
List-Id: User questions <freebsd-questions.freebsd.org>
List-Archive: https://lists.freebsd.org/archives/freebsd-questions
List-Help: <mailto:questions+help@freebsd.org>
List-Post: <mailto:questions@freebsd.org>
List-Subscribe: <mailto:questions+subscribe@freebsd.org>
List-Unsubscribe: <mailto:questions+unsubscribe@freebsd.org>
Sender: owner-freebsd-questions@freebsd.org
X-BeenThere: freebsd-questions@freebsd.org
MIME-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1057408_100966155.1642511026143"
References: <366091554.1057409.1642511026145.ref@mail.yahoo.com>
X-Mailer: WebService/1.1.19594 YMailNorrin
X-Rspamd-Queue-Id: 4JdTVp0vfyz3NVk
X-Spamd-Bar: -
Authentication-Results: mx1.freebsd.org;
	dkim=pass header.d=yahoo.com header.s=s2048 header.b=hqc83GBn;
	dmarc=pass (policy=reject) header.from=yahoo.com;
	spf=pass (mx1.freebsd.org: domain of sagarawmw@yahoo.com designates 98.137.65.146 as permitted sender) smtp.mailfrom=sagarawmw@yahoo.com
X-Spamd-Result: default: False [-1.00 / 15.00];
	 FREEMAIL_FROM(0.00)[yahoo.com];
	 R_SPF_ALLOW(-0.20)[+ptr:yahoo.com];
	 MID_RHS_MATCH_FROMTLD(0.00)[];
	 DKIM_TRACE(0.00)[yahoo.com:+];
	 DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject];
	 FROM_EQ_ENVFROM(0.00)[];
	 RCVD_TLS_LAST(0.00)[];
	 MIME_TRACE(0.00)[0:+,1:+,2:~];
	 FREEMAIL_ENVFROM(0.00)[yahoo.com];
	 ASN(0.00)[asn:36647, ipnet:98.137.64.0/20, country:US];
	 DWL_DNSWL_NONE(0.00)[yahoo.com:dkim];
	 SUBJECT_ENDS_QUESTION(1.00)[];
	 ARC_NA(0.00)[];
	 R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048];
	 NEURAL_HAM_MEDIUM(-1.00)[-1.000];
	 FROM_HAS_DN(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 NEURAL_HAM_LONG(-1.00)[-1.000];
	 MIME_GOOD(-0.10)[multipart/alternative,text/plain];
	 NEURAL_SPAM_SHORT(1.00)[1.000];
	 RCPT_COUNT_ONE(0.00)[1];
	 RCVD_IN_DNSWL_NONE(0.00)[98.137.65.146:from];
	 TO_DN_EQ_ADDR_ALL(0.00)[];
	 MLMMJ_DEST(0.00)[freebsd-questions];
	 RWL_MAILSPIKE_POSSIBLE(0.00)[98.137.65.146:from];
	 RCVD_COUNT_TWO(0.00)[2]
X-ThisMailContainsUnwantedMimeParts: N

------=_Part_1057408_100966155.1642511026143
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi=C2=A0
I'm trying to skip=C2=A0clang AddressSanitizer instrumentation for=C2=A0isM=
atch(void *ptr) function. How to do this on FreeBSD?=C2=A0
My test program:
#include <string.h>#include <stdio.h>#include <stdlib.h>
=C2=A0#define=C2=A0 PATTERN1=C2=A0 =C2=A00x4ffcf694=C2=A0static unsigned ch=
ar pattern1[] =3D {0x4f,0xfc,0xf6,0x94};

__attribute__((no_sanitize("address")))=C2=A0int isMatch(void *ptr);
int main(int argc, char *argv[]){=C2=A0int rv =3D 0;=C2=A0void *ptr =3D NUL=
L;
=C2=A0ptr =3D malloc(4);=C2=A0if (!ptr)=C2=A0 =C2=A0 {=C2=A0 =C2=A0 =C2=A0p=
rintf("No memory.");=C2=A0 =C2=A0 =C2=A0exit(1);=C2=A0 =C2=A0 }=C2=A0=C2=A0=
/* Copy PATTERN1 marker to the allocated block */=C2=A0memcpy(ptr, pattern1=
, sizeof(pattern1));
=C2=A0/*=C2=A0 TEST 1: Correct case.=C2=A0*/=C2=A0printf("TEST 1: Correct c=
ase.\n");=C2=A0rv =3D isMatch(ptr);=C2=A0if (rv =3D=3D 1)=C2=A0 =C2=A0 prin=
tf("Matched\n");=C2=A0else=C2=A0 =C2=A0 printf("NOT Matched\n");

=C2=A0/*=C2=A0 TEST 2: ptr - 1000=C2=A0*/=C2=A0printf("TEST 2: ptr - 1000\n=
");=C2=A0rv =3D isMatch(ptr - 1000);=C2=A0if (rv =3D=3D 1)=C2=A0 =C2=A0 pri=
ntf("Matched\n");=C2=A0else=C2=A0 =C2=A0 printf("NOT Matched\n");
}
__attribute__((no_sanitize("address")))=C2=A0int isMatch(void *ptr){=C2=A0i=
f ((memcmp(ptr, (void *)pattern1, sizeof(pattern1)) =3D=3D 0))=C2=A0 =C2=A0=
 return 1;=C2=A0=C2=A0return 0;}

/usr/local/bin/clang13 prog.c -O1 -g -fsanitize=3Daddress -fno-omit-frame-p=
ointer -Wall -O -I. -I/usr/local/include -L. -L/usr/local/lib -o prog

When run I get following:./progTEST 1: Correct case.MatchedTEST 2: ptr - 10=
00AddressSanitizer:DEADLYSIGNAL=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D29072=3D=3DERROR: AddressSanitizer: SEGV on unknown address 0x601f=
fff00010 (pc 0x0000002bb794 bp 0x7fffffffea30 sp 0x7fffffffea30 T0)=3D=3D29=
072=3D=3DThe signal is caused by a READ memory access.=C2=A0 =C2=A0 #0 0x2b=
b794 in isMatch path/prog.c:67:7=C2=A0 =C2=A0 #1 0x2bb73e in main path/prog=
.c:56:7=C2=A0 =C2=A0 #2 0x236d3f in _start /usr/src/lib/csu/amd64/crt1_c.c:=
75:7=C2=A0 =C2=A0 #3 0x8002e2007=C2=A0 (<unknown module>)
AddressSanitizer can not provide additional info.SUMMARY: AddressSanitizer:=
 SEGV path/prog.c:67:7 in isMatch=3D=3D29072=3D=3DABORTING
Appreciate any help.
Best regardsSagara
=C2=A0


------=_Part_1057408_100966155.1642511026143
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"yahoo-style-wrap" style=3D"font-fami=
ly:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir=
=3D"ltr" data-setdir=3D"false">Hi&nbsp;</div><div dir=3D"ltr" data-setdir=
=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">I'm trying to s=
kip&nbsp;<span>clang AddressSanitizer instrumentation for&nbsp;<span>isMatc=
h(void *ptr) function. How to do this on FreeBSD?&nbsp;</span></span></div>=
<div dir=3D"ltr" data-setdir=3D"false"><span><span><br></span></span></div>=
<div dir=3D"ltr" data-setdir=3D"false">My test program:</div><div dir=3D"lt=
r" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false"><=
div><div>#include &lt;string.h&gt;</div><div>#include &lt;stdio.h&gt;</div>=
<div>#include &lt;stdlib.h&gt;</div><div><br></div><div>&nbsp;#define&nbsp;=
 PATTERN1&nbsp; &nbsp;0x4ffcf694</div><div>&nbsp;static unsigned char patte=
rn1[] =3D {0x4f,0xfc,0xf6,0x94};</div><div><br></div><div><br></div><div>__=
attribute__((no_sanitize("address")))&nbsp;</div><div>int isMatch(void *ptr=
);</div><div><br></div><div>int main(int argc, char *argv[])</div><div>{</d=
iv><div>&nbsp;int rv =3D 0;</div><div>&nbsp;void *ptr =3D NULL;</div><div><=
br></div><div>&nbsp;ptr =3D malloc(4);</div><div>&nbsp;if (!ptr)</div><div>=
&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp;printf("No memory.");</div><d=
iv>&nbsp; &nbsp; &nbsp;exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp;<=
/div><div>&nbsp;/* Copy PATTERN1 marker to the allocated block */</div><div=
>&nbsp;memcpy(ptr, pattern1, sizeof(pattern1));</div><div><br></div><div>&n=
bsp;/*</div><div>&nbsp; TEST 1: Correct case.</div><div>&nbsp;*/</div><div>=
&nbsp;printf("TEST 1: Correct case.\n");</div><div>&nbsp;rv =3D isMatch(ptr=
);</div><div>&nbsp;if (rv =3D=3D 1)</div><div>&nbsp; &nbsp; printf("Matched=
\n");</div><div>&nbsp;else</div><div>&nbsp; &nbsp; printf("NOT Matched\n");=
</div><div><br></div><div><br></div><div>&nbsp;/*</div><div>&nbsp; TEST 2: =
ptr - 1000</div><div>&nbsp;*/</div><div>&nbsp;printf("TEST 2: ptr - 1000\n"=
);</div><div>&nbsp;rv =3D isMatch(ptr - 1000);</div><div>&nbsp;if (rv =3D=
=3D 1)</div><div>&nbsp; &nbsp; printf("Matched\n");</div><div>&nbsp;else</d=
iv><div>&nbsp; &nbsp; printf("NOT Matched\n");</div><div><br></div><div>}</=
div><div><br></div><div>__attribute__((no_sanitize("address")))&nbsp;</div>=
<div>int isMatch(void *ptr)</div><div>{</div><div>&nbsp;if ((memcmp(ptr, (v=
oid *)pattern1, sizeof(pattern1)) =3D=3D 0))</div><div>&nbsp; &nbsp; return=
 1;</div><div>&nbsp;</div><div>&nbsp;return 0;</div><div>}</div><div><br></=
div></div><div><br></div></div><div dir=3D"ltr" data-setdir=3D"false"><span=
>/usr/local/bin/clang13 prog.c -O1 -g -fsanitize=3Daddress -fno-omit-frame-=
pointer -Wall -O -I. -I/usr/local/include -L. -L/usr/local/lib -o prog</spa=
n></div><div dir=3D"ltr" data-setdir=3D"false"><span><br></span></div><div =
dir=3D"ltr" data-setdir=3D"false"><span><br></span></div><div dir=3D"ltr" d=
ata-setdir=3D"false"><span>When run I get following:</span></div><div dir=
=3D"ltr" data-setdir=3D"false"><div><div>./prog</div><div>TEST 1: Correct c=
ase.</div><div>Matched</div><div>TEST 2: ptr - 1000</div><div>AddressSaniti=
zer:DEADLYSIGNAL</div><div>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</d=
iv><div>=3D=3D29072=3D=3DERROR: AddressSanitizer: SEGV on unknown address 0=
x601ffff00010 (pc 0x0000002bb794 bp 0x7fffffffea30 sp 0x7fffffffea30 T0)</d=
iv><div>=3D=3D29072=3D=3DThe signal is caused by a READ memory access.</div=
><div>&nbsp; &nbsp; #0 0x2bb794 in isMatch path/prog.c:67:7</div><div>&nbsp=
; &nbsp; #1 0x2bb73e in main path/prog.c:56:7</div><div>&nbsp; &nbsp; #2 0x=
236d3f in _start /usr/src/lib/csu/amd64/crt1_c.c:75:7</div><div>&nbsp; &nbs=
p; #3 0x8002e2007&nbsp; (&lt;unknown module&gt;)</div><div><br></div><div>A=
ddressSanitizer can not provide additional info.</div><div>SUMMARY: Address=
Sanitizer: SEGV path/prog.c:67:7 in isMatch</div><div>=3D=3D29072=3D=3DABOR=
TING</div><div><br></div></div><div dir=3D"ltr" data-setdir=3D"false">Appre=
ciate any help.</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div =
dir=3D"ltr" data-setdir=3D"false">Best regards</div><div dir=3D"ltr" data-s=
etdir=3D"false">Sagara</div><div dir=3D"ltr" data-setdir=3D"false"><br></di=
v></div><div dir=3D"ltr" data-setdir=3D"false"><span>&nbsp;</span><br></div=
><div dir=3D"ltr" data-setdir=3D"false"><br></div></div></body></html>
------=_Part_1057408_100966155.1642511026143--